react-server-dom-webpack 19.0.0-rc-4c2e457c7c-20240522 → 19.0.0-rc-6f23540c7d-20240528

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.
@@ -417,29 +417,45 @@ function error(format) {
417
417
  printWarning('error', format, args);
418
418
  }
419
419
  }
420
- }
420
+ } // eslint-disable-next-line react-internal/no-production-logging
421
421
 
422
422
  function printWarning(level, format, args) {
423
423
  // When changing this logic, you might want to also
424
424
  // update consoleWithStackDev.www.js as well.
425
425
  {
426
- var stack = ReactSharedInternals.getStackAddendum();
427
-
428
- if (stack !== '') {
429
- format += '%s';
430
- args = args.concat([stack]);
431
- } // eslint-disable-next-line react-internal/safe-string-coercion
426
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
432
427
 
428
+ if (ReactSharedInternals.getCurrentStack) {
429
+ // We only add the current stack to the console when createTask is not supported.
430
+ // Since createTask requires DevTools to be open to work, this means that stacks
431
+ // can be lost while DevTools isn't open but we can't detect this.
432
+ var stack = ReactSharedInternals.getCurrentStack();
433
433
 
434
- var argsWithFormat = args.map(function (item) {
435
- return String(item);
436
- }); // Careful: RN currently depends on this prefix
434
+ if (stack !== '') {
435
+ format += '%s';
436
+ args = args.concat([stack]);
437
+ }
438
+ }
437
439
 
438
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
440
+ if (isErrorLogger) {
441
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
442
+ // Don't toString the arguments.
443
+ args.unshift(format);
444
+ } else {
445
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
446
+ // instead do it at each callsite as needed.
447
+ // Careful: RN currently depends on this prefix
448
+ // eslint-disable-next-line react-internal/safe-string-coercion
449
+ args = args.map(function (item) {
450
+ return String(item);
451
+ });
452
+ args.unshift('Warning: ' + format);
453
+ } // We intentionally don't use spread (or .apply) directly because it
439
454
  // breaks IE9: https://github.com/facebook/react/issues/13610
440
455
  // eslint-disable-next-line react-internal/no-production-logging
441
456
 
442
- Function.prototype.apply.call(console[level], console, argsWithFormat);
457
+
458
+ Function.prototype.apply.call(console[level], console, args);
443
459
  }
444
460
  }
445
461
 
@@ -1960,7 +1976,8 @@ function nullRefGetter() {
1960
1976
  }
1961
1977
 
1962
1978
  function createElement(type, key, props, owner, // DEV-only
1963
- stack) // DEV-only
1979
+ stack, // DEV-only
1980
+ validated) // DEV-only
1964
1981
  {
1965
1982
  var element;
1966
1983
 
@@ -1988,7 +2005,7 @@ stack) // DEV-only
1988
2005
  configurable: false,
1989
2006
  enumerable: false,
1990
2007
  writable: true,
1991
- value: true // This element has already been validated on the server.
2008
+ value: 1 // Whether the element has already been validated on the server.
1992
2009
 
1993
2010
  }); // debugInfo contains Server Component debug information.
1994
2011
 
@@ -436,29 +436,45 @@ function error(format) {
436
436
  printWarning('error', format, args);
437
437
  }
438
438
  }
439
- }
439
+ } // eslint-disable-next-line react-internal/no-production-logging
440
440
 
441
441
  function printWarning(level, format, args) {
442
442
  // When changing this logic, you might want to also
443
443
  // update consoleWithStackDev.www.js as well.
444
444
  {
445
- var stack = ReactSharedInternals.getStackAddendum();
446
-
447
- if (stack !== '') {
448
- format += '%s';
449
- args = args.concat([stack]);
450
- } // eslint-disable-next-line react-internal/safe-string-coercion
445
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
451
446
 
447
+ if (ReactSharedInternals.getCurrentStack) {
448
+ // We only add the current stack to the console when createTask is not supported.
449
+ // Since createTask requires DevTools to be open to work, this means that stacks
450
+ // can be lost while DevTools isn't open but we can't detect this.
451
+ var stack = ReactSharedInternals.getCurrentStack();
452
452
 
453
- var argsWithFormat = args.map(function (item) {
454
- return String(item);
455
- }); // Careful: RN currently depends on this prefix
453
+ if (stack !== '') {
454
+ format += '%s';
455
+ args = args.concat([stack]);
456
+ }
457
+ }
456
458
 
457
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
459
+ if (isErrorLogger) {
460
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
461
+ // Don't toString the arguments.
462
+ args.unshift(format);
463
+ } else {
464
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
465
+ // instead do it at each callsite as needed.
466
+ // Careful: RN currently depends on this prefix
467
+ // eslint-disable-next-line react-internal/safe-string-coercion
468
+ args = args.map(function (item) {
469
+ return String(item);
470
+ });
471
+ args.unshift('Warning: ' + format);
472
+ } // We intentionally don't use spread (or .apply) directly because it
458
473
  // breaks IE9: https://github.com/facebook/react/issues/13610
459
474
  // eslint-disable-next-line react-internal/no-production-logging
460
475
 
461
- Function.prototype.apply.call(console[level], console, argsWithFormat);
476
+
477
+ Function.prototype.apply.call(console[level], console, args);
462
478
  }
463
479
  }
464
480
 
@@ -2213,7 +2229,8 @@ function nullRefGetter() {
2213
2229
  }
2214
2230
 
2215
2231
  function createElement(type, key, props, owner, // DEV-only
2216
- stack) // DEV-only
2232
+ stack, // DEV-only
2233
+ validated) // DEV-only
2217
2234
  {
2218
2235
  var element;
2219
2236
 
@@ -2241,7 +2258,7 @@ stack) // DEV-only
2241
2258
  configurable: false,
2242
2259
  enumerable: false,
2243
2260
  writable: true,
2244
- value: true // This element has already been validated on the server.
2261
+ value: 1 // Whether the element has already been validated on the server.
2245
2262
 
2246
2263
  }); // debugInfo contains Server Component debug information.
2247
2264
 
@@ -437,29 +437,45 @@ function error(format) {
437
437
  printWarning('error', format, args);
438
438
  }
439
439
  }
440
- }
440
+ } // eslint-disable-next-line react-internal/no-production-logging
441
441
 
442
442
  function printWarning(level, format, args) {
443
443
  // When changing this logic, you might want to also
444
444
  // update consoleWithStackDev.www.js as well.
445
445
  {
446
- var stack = ReactSharedInternals.getStackAddendum();
447
-
448
- if (stack !== '') {
449
- format += '%s';
450
- args = args.concat([stack]);
451
- } // eslint-disable-next-line react-internal/safe-string-coercion
446
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
452
447
 
448
+ if (ReactSharedInternals.getCurrentStack) {
449
+ // We only add the current stack to the console when createTask is not supported.
450
+ // Since createTask requires DevTools to be open to work, this means that stacks
451
+ // can be lost while DevTools isn't open but we can't detect this.
452
+ var stack = ReactSharedInternals.getCurrentStack();
453
453
 
454
- var argsWithFormat = args.map(function (item) {
455
- return String(item);
456
- }); // Careful: RN currently depends on this prefix
454
+ if (stack !== '') {
455
+ format += '%s';
456
+ args = args.concat([stack]);
457
+ }
458
+ }
457
459
 
458
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
460
+ if (isErrorLogger) {
461
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
462
+ // Don't toString the arguments.
463
+ args.unshift(format);
464
+ } else {
465
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
466
+ // instead do it at each callsite as needed.
467
+ // Careful: RN currently depends on this prefix
468
+ // eslint-disable-next-line react-internal/safe-string-coercion
469
+ args = args.map(function (item) {
470
+ return String(item);
471
+ });
472
+ args.unshift('Warning: ' + format);
473
+ } // We intentionally don't use spread (or .apply) directly because it
459
474
  // breaks IE9: https://github.com/facebook/react/issues/13610
460
475
  // eslint-disable-next-line react-internal/no-production-logging
461
476
 
462
- Function.prototype.apply.call(console[level], console, argsWithFormat);
477
+
478
+ Function.prototype.apply.call(console[level], console, args);
463
479
  }
464
480
  }
465
481
 
@@ -2211,7 +2227,8 @@ function nullRefGetter() {
2211
2227
  }
2212
2228
 
2213
2229
  function createElement(type, key, props, owner, // DEV-only
2214
- stack) // DEV-only
2230
+ stack, // DEV-only
2231
+ validated) // DEV-only
2215
2232
  {
2216
2233
  var element;
2217
2234
 
@@ -2239,7 +2256,7 @@ stack) // DEV-only
2239
2256
  configurable: false,
2240
2257
  enumerable: false,
2241
2258
  writable: true,
2242
- value: true // This element has already been validated on the server.
2259
+ value: 1 // Whether the element has already been validated on the server.
2243
2260
 
2244
2261
  }); // debugInfo contains Server Component debug information.
2245
2262
 
@@ -390,29 +390,45 @@ function error(format) {
390
390
  printWarning('error', format, args);
391
391
  }
392
392
  }
393
- }
393
+ } // eslint-disable-next-line react-internal/no-production-logging
394
394
 
395
395
  function printWarning(level, format, args) {
396
396
  // When changing this logic, you might want to also
397
397
  // update consoleWithStackDev.www.js as well.
398
398
  {
399
- var stack = ReactSharedInternals.getStackAddendum();
400
-
401
- if (stack !== '') {
402
- format += '%s';
403
- args = args.concat([stack]);
404
- } // eslint-disable-next-line react-internal/safe-string-coercion
399
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
405
400
 
401
+ if (ReactSharedInternals.getCurrentStack) {
402
+ // We only add the current stack to the console when createTask is not supported.
403
+ // Since createTask requires DevTools to be open to work, this means that stacks
404
+ // can be lost while DevTools isn't open but we can't detect this.
405
+ var stack = ReactSharedInternals.getCurrentStack();
406
406
 
407
- var argsWithFormat = args.map(function (item) {
408
- return String(item);
409
- }); // Careful: RN currently depends on this prefix
407
+ if (stack !== '') {
408
+ format += '%s';
409
+ args = args.concat([stack]);
410
+ }
411
+ }
410
412
 
411
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
413
+ if (isErrorLogger) {
414
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
415
+ // Don't toString the arguments.
416
+ args.unshift(format);
417
+ } else {
418
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
419
+ // instead do it at each callsite as needed.
420
+ // Careful: RN currently depends on this prefix
421
+ // eslint-disable-next-line react-internal/safe-string-coercion
422
+ args = args.map(function (item) {
423
+ return String(item);
424
+ });
425
+ args.unshift('Warning: ' + format);
426
+ } // We intentionally don't use spread (or .apply) directly because it
412
427
  // breaks IE9: https://github.com/facebook/react/issues/13610
413
428
  // eslint-disable-next-line react-internal/no-production-logging
414
429
 
415
- Function.prototype.apply.call(console[level], console, argsWithFormat);
430
+
431
+ Function.prototype.apply.call(console[level], console, args);
416
432
  }
417
433
  }
418
434
 
@@ -2164,7 +2180,8 @@ function nullRefGetter() {
2164
2180
  }
2165
2181
 
2166
2182
  function createElement(type, key, props, owner, // DEV-only
2167
- stack) // DEV-only
2183
+ stack, // DEV-only
2184
+ validated) // DEV-only
2168
2185
  {
2169
2186
  var element;
2170
2187
 
@@ -2192,7 +2209,7 @@ stack) // DEV-only
2192
2209
  configurable: false,
2193
2210
  enumerable: false,
2194
2211
  writable: true,
2195
- value: true // This element has already been validated on the server.
2212
+ value: 1 // Whether the element has already been validated on the server.
2196
2213
 
2197
2214
  }); // debugInfo contains Server Component debug information.
2198
2215
 
@@ -39,6 +39,9 @@ if (!ReactSharedInternalsServer) {
39
39
  throw new Error('The "react" package in this environment is not configured correctly. ' + 'The "react-server" condition must be enabled in any environment that ' + 'runs React Server Components.');
40
40
  }
41
41
 
42
+ // -----------------------------------------------------------------------------
43
+ var enablePostpone = false;
44
+
42
45
  function error(format) {
43
46
  {
44
47
  {
@@ -49,35 +52,48 @@ function error(format) {
49
52
  printWarning('error', format, args);
50
53
  }
51
54
  }
52
- }
55
+ } // eslint-disable-next-line react-internal/no-production-logging
53
56
 
54
57
  function printWarning(level, format, args) {
55
58
  // When changing this logic, you might want to also
56
59
  // update consoleWithStackDev.www.js as well.
57
60
  {
58
- var stack = ReactSharedInternalsServer.getStackAddendum();
59
-
60
- if (stack !== '') {
61
- format += '%s';
62
- args = args.concat([stack]);
63
- } // eslint-disable-next-line react-internal/safe-string-coercion
61
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
64
62
 
63
+ if (ReactSharedInternalsServer.getCurrentStack) {
64
+ // We only add the current stack to the console when createTask is not supported.
65
+ // Since createTask requires DevTools to be open to work, this means that stacks
66
+ // can be lost while DevTools isn't open but we can't detect this.
67
+ var stack = ReactSharedInternalsServer.getCurrentStack();
65
68
 
66
- var argsWithFormat = args.map(function (item) {
67
- return String(item);
68
- }); // Careful: RN currently depends on this prefix
69
+ if (stack !== '') {
70
+ format += '%s';
71
+ args = args.concat([stack]);
72
+ }
73
+ }
69
74
 
70
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
75
+ if (isErrorLogger) {
76
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
77
+ // Don't toString the arguments.
78
+ args.unshift(format);
79
+ } else {
80
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
81
+ // instead do it at each callsite as needed.
82
+ // Careful: RN currently depends on this prefix
83
+ // eslint-disable-next-line react-internal/safe-string-coercion
84
+ args = args.map(function (item) {
85
+ return String(item);
86
+ });
87
+ args.unshift('Warning: ' + format);
88
+ } // We intentionally don't use spread (or .apply) directly because it
71
89
  // breaks IE9: https://github.com/facebook/react/issues/13610
72
90
  // eslint-disable-next-line react-internal/no-production-logging
73
91
 
74
- Function.prototype.apply.call(console[level], console, argsWithFormat);
92
+
93
+ Function.prototype.apply.call(console[level], console, args);
75
94
  }
76
95
  }
77
96
 
78
- // -----------------------------------------------------------------------------
79
- var enablePostpone = false;
80
-
81
97
  function scheduleWork(callback) {
82
98
  callback();
83
99
  }
@@ -1572,6 +1588,7 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
1572
1588
 
1573
1589
  {
1574
1590
  request.environmentName = environmentName === undefined ? 'Server' : environmentName;
1591
+ request.didWarnForKey = null;
1575
1592
  }
1576
1593
 
1577
1594
  var rootTask = createTask(request, model, null, false, abortSet);
@@ -1951,7 +1968,8 @@ function callLazyInitInDEV(lazy) {
1951
1968
  }
1952
1969
 
1953
1970
  function renderFunctionComponent(request, task, key, Component, props, owner, // DEV-only
1954
- stack) // DEV-only
1971
+ stack, // DEV-only
1972
+ validated) // DEV-only
1955
1973
  {
1956
1974
  // Reset the task's thenable state before continuing, so that if a later
1957
1975
  // component suspends we can reuse the same task object. If the same
@@ -1999,6 +2017,17 @@ stack) // DEV-only
1999
2017
  // to its value without a wrapper if it's synchronously available.
2000
2018
  var thenable = result;
2001
2019
 
2020
+ {
2021
+ // If the thenable resolves to an element, then it was in a static position,
2022
+ // the return value of a Server Component. That doesn't need further validation
2023
+ // of keys. The Server Component itself would have had a key.
2024
+ thenable.then(function (resolvedValue) {
2025
+ if (typeof resolvedValue === 'object' && resolvedValue !== null && resolvedValue.$$typeof === REACT_ELEMENT_TYPE) {
2026
+ resolvedValue._store.validated = 1;
2027
+ }
2028
+ }, function () {});
2029
+ }
2030
+
2002
2031
  if (thenable.status === 'fulfilled') {
2003
2032
  return thenable.value;
2004
2033
  } // TODO: Once we accept Promises as children on the client, we can just return
@@ -2069,6 +2098,11 @@ stack) // DEV-only
2069
2098
  {
2070
2099
  result._debugInfo = _iterableChild._debugInfo;
2071
2100
  }
2101
+ } else if (result.$$typeof === REACT_ELEMENT_TYPE) {
2102
+ // If the server component renders to an element, then it was in a static position.
2103
+ // That doesn't need further validation of keys. The Server Component itself would
2104
+ // have had a key.
2105
+ result._store.validated = 1;
2072
2106
  }
2073
2107
  } // Track this element's key on the Server Component on the keyPath context..
2074
2108
 
@@ -2095,6 +2129,20 @@ stack) // DEV-only
2095
2129
  }
2096
2130
 
2097
2131
  function renderFragment(request, task, children) {
2132
+ {
2133
+ for (var i = 0; i < children.length; i++) {
2134
+ var child = children[i];
2135
+
2136
+ if (child !== null && typeof child === 'object' && child.$$typeof === REACT_ELEMENT_TYPE) {
2137
+ var element = child;
2138
+
2139
+ if (element.key === null && !element._store.validated) {
2140
+ element._store.validated = 2;
2141
+ }
2142
+ }
2143
+ }
2144
+ }
2145
+
2098
2146
  if (task.keyPath !== null) {
2099
2147
  // We have a Server Component that specifies a key but we're now splitting
2100
2148
  // the tree using a fragment.
@@ -2188,7 +2236,8 @@ function renderAsyncFragment(request, task, children, getAsyncIterator) {
2188
2236
  }
2189
2237
 
2190
2238
  function renderClientElement(task, type, key, props, owner, // DEV-only
2191
- stack) // DEV-only
2239
+ stack, // DEV-only
2240
+ validated) // DEV-only
2192
2241
  {
2193
2242
  // We prepend the terminal client element that actually gets serialized with
2194
2243
  // the keys of any Server Components which are not serialized.
@@ -2239,7 +2288,8 @@ function outlineTask(request, task) {
2239
2288
  }
2240
2289
 
2241
2290
  function renderElement(request, task, type, key, ref, props, owner, // DEV only
2242
- stack) // DEV only
2291
+ stack, // DEV only
2292
+ validated) // DEV only
2243
2293
  {
2244
2294
  if (ref !== null && ref !== undefined) {
2245
2295
  // When the ref moves to the regular props object this will implicitly
@@ -39,6 +39,9 @@ if (!ReactSharedInternalsServer) {
39
39
  throw new Error('The "react" package in this environment is not configured correctly. ' + 'The "react-server" condition must be enabled in any environment that ' + 'runs React Server Components.');
40
40
  }
41
41
 
42
+ // -----------------------------------------------------------------------------
43
+ var enablePostpone = false;
44
+
42
45
  function error(format) {
43
46
  {
44
47
  {
@@ -49,35 +52,48 @@ function error(format) {
49
52
  printWarning('error', format, args);
50
53
  }
51
54
  }
52
- }
55
+ } // eslint-disable-next-line react-internal/no-production-logging
53
56
 
54
57
  function printWarning(level, format, args) {
55
58
  // When changing this logic, you might want to also
56
59
  // update consoleWithStackDev.www.js as well.
57
60
  {
58
- var stack = ReactSharedInternalsServer.getStackAddendum();
59
-
60
- if (stack !== '') {
61
- format += '%s';
62
- args = args.concat([stack]);
63
- } // eslint-disable-next-line react-internal/safe-string-coercion
61
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
64
62
 
63
+ if (ReactSharedInternalsServer.getCurrentStack) {
64
+ // We only add the current stack to the console when createTask is not supported.
65
+ // Since createTask requires DevTools to be open to work, this means that stacks
66
+ // can be lost while DevTools isn't open but we can't detect this.
67
+ var stack = ReactSharedInternalsServer.getCurrentStack();
65
68
 
66
- var argsWithFormat = args.map(function (item) {
67
- return String(item);
68
- }); // Careful: RN currently depends on this prefix
69
+ if (stack !== '') {
70
+ format += '%s';
71
+ args = args.concat([stack]);
72
+ }
73
+ }
69
74
 
70
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
75
+ if (isErrorLogger) {
76
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
77
+ // Don't toString the arguments.
78
+ args.unshift(format);
79
+ } else {
80
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
81
+ // instead do it at each callsite as needed.
82
+ // Careful: RN currently depends on this prefix
83
+ // eslint-disable-next-line react-internal/safe-string-coercion
84
+ args = args.map(function (item) {
85
+ return String(item);
86
+ });
87
+ args.unshift('Warning: ' + format);
88
+ } // We intentionally don't use spread (or .apply) directly because it
71
89
  // breaks IE9: https://github.com/facebook/react/issues/13610
72
90
  // eslint-disable-next-line react-internal/no-production-logging
73
91
 
74
- Function.prototype.apply.call(console[level], console, argsWithFormat);
92
+
93
+ Function.prototype.apply.call(console[level], console, args);
75
94
  }
76
95
  }
77
96
 
78
- // -----------------------------------------------------------------------------
79
- var enablePostpone = false;
80
-
81
97
  function scheduleWork(callback) {
82
98
  setTimeout(callback, 0);
83
99
  }
@@ -1585,6 +1601,7 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
1585
1601
 
1586
1602
  {
1587
1603
  request.environmentName = environmentName === undefined ? 'Server' : environmentName;
1604
+ request.didWarnForKey = null;
1588
1605
  }
1589
1606
 
1590
1607
  var rootTask = createTask(request, model, null, false, abortSet);
@@ -1972,7 +1989,8 @@ function callLazyInitInDEV(lazy) {
1972
1989
  }
1973
1990
 
1974
1991
  function renderFunctionComponent(request, task, key, Component, props, owner, // DEV-only
1975
- stack) // DEV-only
1992
+ stack, // DEV-only
1993
+ validated) // DEV-only
1976
1994
  {
1977
1995
  // Reset the task's thenable state before continuing, so that if a later
1978
1996
  // component suspends we can reuse the same task object. If the same
@@ -2020,6 +2038,17 @@ stack) // DEV-only
2020
2038
  // to its value without a wrapper if it's synchronously available.
2021
2039
  var thenable = result;
2022
2040
 
2041
+ {
2042
+ // If the thenable resolves to an element, then it was in a static position,
2043
+ // the return value of a Server Component. That doesn't need further validation
2044
+ // of keys. The Server Component itself would have had a key.
2045
+ thenable.then(function (resolvedValue) {
2046
+ if (typeof resolvedValue === 'object' && resolvedValue !== null && resolvedValue.$$typeof === REACT_ELEMENT_TYPE) {
2047
+ resolvedValue._store.validated = 1;
2048
+ }
2049
+ }, function () {});
2050
+ }
2051
+
2023
2052
  if (thenable.status === 'fulfilled') {
2024
2053
  return thenable.value;
2025
2054
  } // TODO: Once we accept Promises as children on the client, we can just return
@@ -2090,6 +2119,11 @@ stack) // DEV-only
2090
2119
  {
2091
2120
  result._debugInfo = _iterableChild._debugInfo;
2092
2121
  }
2122
+ } else if (result.$$typeof === REACT_ELEMENT_TYPE) {
2123
+ // If the server component renders to an element, then it was in a static position.
2124
+ // That doesn't need further validation of keys. The Server Component itself would
2125
+ // have had a key.
2126
+ result._store.validated = 1;
2093
2127
  }
2094
2128
  } // Track this element's key on the Server Component on the keyPath context..
2095
2129
 
@@ -2116,6 +2150,20 @@ stack) // DEV-only
2116
2150
  }
2117
2151
 
2118
2152
  function renderFragment(request, task, children) {
2153
+ {
2154
+ for (var i = 0; i < children.length; i++) {
2155
+ var child = children[i];
2156
+
2157
+ if (child !== null && typeof child === 'object' && child.$$typeof === REACT_ELEMENT_TYPE) {
2158
+ var element = child;
2159
+
2160
+ if (element.key === null && !element._store.validated) {
2161
+ element._store.validated = 2;
2162
+ }
2163
+ }
2164
+ }
2165
+ }
2166
+
2119
2167
  if (task.keyPath !== null) {
2120
2168
  // We have a Server Component that specifies a key but we're now splitting
2121
2169
  // the tree using a fragment.
@@ -2209,7 +2257,8 @@ function renderAsyncFragment(request, task, children, getAsyncIterator) {
2209
2257
  }
2210
2258
 
2211
2259
  function renderClientElement(task, type, key, props, owner, // DEV-only
2212
- stack) // DEV-only
2260
+ stack, // DEV-only
2261
+ validated) // DEV-only
2213
2262
  {
2214
2263
  // We prepend the terminal client element that actually gets serialized with
2215
2264
  // the keys of any Server Components which are not serialized.
@@ -2260,7 +2309,8 @@ function outlineTask(request, task) {
2260
2309
  }
2261
2310
 
2262
2311
  function renderElement(request, task, type, key, ref, props, owner, // DEV only
2263
- stack) // DEV only
2312
+ stack, // DEV only
2313
+ validated) // DEV only
2264
2314
  {
2265
2315
  if (ref !== null && ref !== undefined) {
2266
2316
  // When the ref moves to the regular props object this will implicitly
@@ -42,6 +42,9 @@ if (!ReactSharedInternalsServer) {
42
42
  throw new Error('The "react" package in this environment is not configured correctly. ' + 'The "react-server" condition must be enabled in any environment that ' + 'runs React Server Components.');
43
43
  }
44
44
 
45
+ // -----------------------------------------------------------------------------
46
+ var enablePostpone = false;
47
+
45
48
  function error(format) {
46
49
  {
47
50
  {
@@ -52,35 +55,48 @@ function error(format) {
52
55
  printWarning('error', format, args);
53
56
  }
54
57
  }
55
- }
58
+ } // eslint-disable-next-line react-internal/no-production-logging
56
59
 
57
60
  function printWarning(level, format, args) {
58
61
  // When changing this logic, you might want to also
59
62
  // update consoleWithStackDev.www.js as well.
60
63
  {
61
- var stack = ReactSharedInternalsServer.getStackAddendum();
62
-
63
- if (stack !== '') {
64
- format += '%s';
65
- args = args.concat([stack]);
66
- } // eslint-disable-next-line react-internal/safe-string-coercion
64
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
67
65
 
66
+ if (ReactSharedInternalsServer.getCurrentStack) {
67
+ // We only add the current stack to the console when createTask is not supported.
68
+ // Since createTask requires DevTools to be open to work, this means that stacks
69
+ // can be lost while DevTools isn't open but we can't detect this.
70
+ var stack = ReactSharedInternalsServer.getCurrentStack();
68
71
 
69
- var argsWithFormat = args.map(function (item) {
70
- return String(item);
71
- }); // Careful: RN currently depends on this prefix
72
+ if (stack !== '') {
73
+ format += '%s';
74
+ args = args.concat([stack]);
75
+ }
76
+ }
72
77
 
73
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
78
+ if (isErrorLogger) {
79
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
80
+ // Don't toString the arguments.
81
+ args.unshift(format);
82
+ } else {
83
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
84
+ // instead do it at each callsite as needed.
85
+ // Careful: RN currently depends on this prefix
86
+ // eslint-disable-next-line react-internal/safe-string-coercion
87
+ args = args.map(function (item) {
88
+ return String(item);
89
+ });
90
+ args.unshift('Warning: ' + format);
91
+ } // We intentionally don't use spread (or .apply) directly because it
74
92
  // breaks IE9: https://github.com/facebook/react/issues/13610
75
93
  // eslint-disable-next-line react-internal/no-production-logging
76
94
 
77
- Function.prototype.apply.call(console[level], console, argsWithFormat);
95
+
96
+ Function.prototype.apply.call(console[level], console, args);
78
97
  }
79
98
  }
80
99
 
81
- // -----------------------------------------------------------------------------
82
- var enablePostpone = false;
83
-
84
100
  function scheduleWork(callback) {
85
101
  setImmediate(callback);
86
102
  }
@@ -1638,6 +1654,7 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
1638
1654
 
1639
1655
  {
1640
1656
  request.environmentName = environmentName === undefined ? 'Server' : environmentName;
1657
+ request.didWarnForKey = null;
1641
1658
  }
1642
1659
 
1643
1660
  var rootTask = createTask(request, model, null, false, abortSet);
@@ -2023,7 +2040,8 @@ function callLazyInitInDEV(lazy) {
2023
2040
  }
2024
2041
 
2025
2042
  function renderFunctionComponent(request, task, key, Component, props, owner, // DEV-only
2026
- stack) // DEV-only
2043
+ stack, // DEV-only
2044
+ validated) // DEV-only
2027
2045
  {
2028
2046
  // Reset the task's thenable state before continuing, so that if a later
2029
2047
  // component suspends we can reuse the same task object. If the same
@@ -2071,6 +2089,17 @@ stack) // DEV-only
2071
2089
  // to its value without a wrapper if it's synchronously available.
2072
2090
  var thenable = result;
2073
2091
 
2092
+ {
2093
+ // If the thenable resolves to an element, then it was in a static position,
2094
+ // the return value of a Server Component. That doesn't need further validation
2095
+ // of keys. The Server Component itself would have had a key.
2096
+ thenable.then(function (resolvedValue) {
2097
+ if (typeof resolvedValue === 'object' && resolvedValue !== null && resolvedValue.$$typeof === REACT_ELEMENT_TYPE) {
2098
+ resolvedValue._store.validated = 1;
2099
+ }
2100
+ }, function () {});
2101
+ }
2102
+
2074
2103
  if (thenable.status === 'fulfilled') {
2075
2104
  return thenable.value;
2076
2105
  } // TODO: Once we accept Promises as children on the client, we can just return
@@ -2141,6 +2170,11 @@ stack) // DEV-only
2141
2170
  {
2142
2171
  result._debugInfo = _iterableChild._debugInfo;
2143
2172
  }
2173
+ } else if (result.$$typeof === REACT_ELEMENT_TYPE) {
2174
+ // If the server component renders to an element, then it was in a static position.
2175
+ // That doesn't need further validation of keys. The Server Component itself would
2176
+ // have had a key.
2177
+ result._store.validated = 1;
2144
2178
  }
2145
2179
  } // Track this element's key on the Server Component on the keyPath context..
2146
2180
 
@@ -2167,6 +2201,20 @@ stack) // DEV-only
2167
2201
  }
2168
2202
 
2169
2203
  function renderFragment(request, task, children) {
2204
+ {
2205
+ for (var i = 0; i < children.length; i++) {
2206
+ var child = children[i];
2207
+
2208
+ if (child !== null && typeof child === 'object' && child.$$typeof === REACT_ELEMENT_TYPE) {
2209
+ var element = child;
2210
+
2211
+ if (element.key === null && !element._store.validated) {
2212
+ element._store.validated = 2;
2213
+ }
2214
+ }
2215
+ }
2216
+ }
2217
+
2170
2218
  if (task.keyPath !== null) {
2171
2219
  // We have a Server Component that specifies a key but we're now splitting
2172
2220
  // the tree using a fragment.
@@ -2260,7 +2308,8 @@ function renderAsyncFragment(request, task, children, getAsyncIterator) {
2260
2308
  }
2261
2309
 
2262
2310
  function renderClientElement(task, type, key, props, owner, // DEV-only
2263
- stack) // DEV-only
2311
+ stack, // DEV-only
2312
+ validated) // DEV-only
2264
2313
  {
2265
2314
  // We prepend the terminal client element that actually gets serialized with
2266
2315
  // the keys of any Server Components which are not serialized.
@@ -2311,7 +2360,8 @@ function outlineTask(request, task) {
2311
2360
  }
2312
2361
 
2313
2362
  function renderElement(request, task, type, key, ref, props, owner, // DEV only
2314
- stack) // DEV only
2363
+ stack, // DEV only
2364
+ validated) // DEV only
2315
2365
  {
2316
2366
  if (ref !== null && ref !== undefined) {
2317
2367
  // When the ref moves to the regular props object this will implicitly
@@ -42,6 +42,9 @@ if (!ReactSharedInternalsServer) {
42
42
  throw new Error('The "react" package in this environment is not configured correctly. ' + 'The "react-server" condition must be enabled in any environment that ' + 'runs React Server Components.');
43
43
  }
44
44
 
45
+ // -----------------------------------------------------------------------------
46
+ var enablePostpone = false;
47
+
45
48
  function error(format) {
46
49
  {
47
50
  {
@@ -52,35 +55,48 @@ function error(format) {
52
55
  printWarning('error', format, args);
53
56
  }
54
57
  }
55
- }
58
+ } // eslint-disable-next-line react-internal/no-production-logging
56
59
 
57
60
  function printWarning(level, format, args) {
58
61
  // When changing this logic, you might want to also
59
62
  // update consoleWithStackDev.www.js as well.
60
63
  {
61
- var stack = ReactSharedInternalsServer.getStackAddendum();
62
-
63
- if (stack !== '') {
64
- format += '%s';
65
- args = args.concat([stack]);
66
- } // eslint-disable-next-line react-internal/safe-string-coercion
64
+ var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n';
67
65
 
66
+ if (ReactSharedInternalsServer.getCurrentStack) {
67
+ // We only add the current stack to the console when createTask is not supported.
68
+ // Since createTask requires DevTools to be open to work, this means that stacks
69
+ // can be lost while DevTools isn't open but we can't detect this.
70
+ var stack = ReactSharedInternalsServer.getCurrentStack();
68
71
 
69
- var argsWithFormat = args.map(function (item) {
70
- return String(item);
71
- }); // Careful: RN currently depends on this prefix
72
+ if (stack !== '') {
73
+ format += '%s';
74
+ args = args.concat([stack]);
75
+ }
76
+ }
72
77
 
73
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
78
+ if (isErrorLogger) {
79
+ // Don't prefix our default logging formatting in ReactFiberErrorLoggger.
80
+ // Don't toString the arguments.
81
+ args.unshift(format);
82
+ } else {
83
+ // TODO: Remove this prefix and stop toStringing in the wrapper and
84
+ // instead do it at each callsite as needed.
85
+ // Careful: RN currently depends on this prefix
86
+ // eslint-disable-next-line react-internal/safe-string-coercion
87
+ args = args.map(function (item) {
88
+ return String(item);
89
+ });
90
+ args.unshift('Warning: ' + format);
91
+ } // We intentionally don't use spread (or .apply) directly because it
74
92
  // breaks IE9: https://github.com/facebook/react/issues/13610
75
93
  // eslint-disable-next-line react-internal/no-production-logging
76
94
 
77
- Function.prototype.apply.call(console[level], console, argsWithFormat);
95
+
96
+ Function.prototype.apply.call(console[level], console, args);
78
97
  }
79
98
  }
80
99
 
81
- // -----------------------------------------------------------------------------
82
- var enablePostpone = false;
83
-
84
100
  function scheduleWork(callback) {
85
101
  setImmediate(callback);
86
102
  }
@@ -1638,6 +1654,7 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
1638
1654
 
1639
1655
  {
1640
1656
  request.environmentName = environmentName === undefined ? 'Server' : environmentName;
1657
+ request.didWarnForKey = null;
1641
1658
  }
1642
1659
 
1643
1660
  var rootTask = createTask(request, model, null, false, abortSet);
@@ -2023,7 +2040,8 @@ function callLazyInitInDEV(lazy) {
2023
2040
  }
2024
2041
 
2025
2042
  function renderFunctionComponent(request, task, key, Component, props, owner, // DEV-only
2026
- stack) // DEV-only
2043
+ stack, // DEV-only
2044
+ validated) // DEV-only
2027
2045
  {
2028
2046
  // Reset the task's thenable state before continuing, so that if a later
2029
2047
  // component suspends we can reuse the same task object. If the same
@@ -2071,6 +2089,17 @@ stack) // DEV-only
2071
2089
  // to its value without a wrapper if it's synchronously available.
2072
2090
  var thenable = result;
2073
2091
 
2092
+ {
2093
+ // If the thenable resolves to an element, then it was in a static position,
2094
+ // the return value of a Server Component. That doesn't need further validation
2095
+ // of keys. The Server Component itself would have had a key.
2096
+ thenable.then(function (resolvedValue) {
2097
+ if (typeof resolvedValue === 'object' && resolvedValue !== null && resolvedValue.$$typeof === REACT_ELEMENT_TYPE) {
2098
+ resolvedValue._store.validated = 1;
2099
+ }
2100
+ }, function () {});
2101
+ }
2102
+
2074
2103
  if (thenable.status === 'fulfilled') {
2075
2104
  return thenable.value;
2076
2105
  } // TODO: Once we accept Promises as children on the client, we can just return
@@ -2141,6 +2170,11 @@ stack) // DEV-only
2141
2170
  {
2142
2171
  result._debugInfo = _iterableChild._debugInfo;
2143
2172
  }
2173
+ } else if (result.$$typeof === REACT_ELEMENT_TYPE) {
2174
+ // If the server component renders to an element, then it was in a static position.
2175
+ // That doesn't need further validation of keys. The Server Component itself would
2176
+ // have had a key.
2177
+ result._store.validated = 1;
2144
2178
  }
2145
2179
  } // Track this element's key on the Server Component on the keyPath context..
2146
2180
 
@@ -2167,6 +2201,20 @@ stack) // DEV-only
2167
2201
  }
2168
2202
 
2169
2203
  function renderFragment(request, task, children) {
2204
+ {
2205
+ for (var i = 0; i < children.length; i++) {
2206
+ var child = children[i];
2207
+
2208
+ if (child !== null && typeof child === 'object' && child.$$typeof === REACT_ELEMENT_TYPE) {
2209
+ var element = child;
2210
+
2211
+ if (element.key === null && !element._store.validated) {
2212
+ element._store.validated = 2;
2213
+ }
2214
+ }
2215
+ }
2216
+ }
2217
+
2170
2218
  if (task.keyPath !== null) {
2171
2219
  // We have a Server Component that specifies a key but we're now splitting
2172
2220
  // the tree using a fragment.
@@ -2260,7 +2308,8 @@ function renderAsyncFragment(request, task, children, getAsyncIterator) {
2260
2308
  }
2261
2309
 
2262
2310
  function renderClientElement(task, type, key, props, owner, // DEV-only
2263
- stack) // DEV-only
2311
+ stack, // DEV-only
2312
+ validated) // DEV-only
2264
2313
  {
2265
2314
  // We prepend the terminal client element that actually gets serialized with
2266
2315
  // the keys of any Server Components which are not serialized.
@@ -2311,7 +2360,8 @@ function outlineTask(request, task) {
2311
2360
  }
2312
2361
 
2313
2362
  function renderElement(request, task, type, key, ref, props, owner, // DEV only
2314
- stack) // DEV only
2363
+ stack, // DEV only
2364
+ validated) // DEV only
2315
2365
  {
2316
2366
  if (ref !== null && ref !== undefined) {
2317
2367
  // When the ref moves to the regular props object this will implicitly
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-server-dom-webpack",
3
3
  "description": "React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
4
- "version": "19.0.0-rc-4c2e457c7c-20240522",
4
+ "version": "19.0.0-rc-6f23540c7d-20240528",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],
@@ -77,8 +77,8 @@
77
77
  "node": ">=0.10.0"
78
78
  },
79
79
  "peerDependencies": {
80
- "react": "19.0.0-rc-4c2e457c7c-20240522",
81
- "react-dom": "19.0.0-rc-4c2e457c7c-20240522",
80
+ "react": "19.0.0-rc-6f23540c7d-20240528",
81
+ "react-dom": "19.0.0-rc-6f23540c7d-20240528",
82
82
  "webpack": "^5.59.0"
83
83
  },
84
84
  "dependencies": {