react-server-dom-webpack 19.0.0-canary-e3ebcd54b-20240405 → 19.0.0-canary-adb717393-20240411

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.
Files changed (38) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +136 -97
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +106 -65
  3. package/cjs/react-server-dom-webpack-client.browser.production.min.js +24 -23
  4. package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -1
  5. package/cjs/react-server-dom-webpack-client.edge.development.js +144 -105
  6. package/cjs/react-server-dom-webpack-client.edge.production.js +114 -73
  7. package/cjs/react-server-dom-webpack-client.edge.production.min.js +24 -23
  8. package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -1
  9. package/cjs/react-server-dom-webpack-client.node.development.js +144 -105
  10. package/cjs/react-server-dom-webpack-client.node.production.js +114 -73
  11. package/cjs/react-server-dom-webpack-client.node.production.min.js +26 -25
  12. package/cjs/react-server-dom-webpack-client.node.production.min.js.map +1 -1
  13. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +144 -105
  14. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +114 -73
  15. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +33 -32
  16. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -1
  17. package/cjs/react-server-dom-webpack-node-register.js.map +1 -1
  18. package/cjs/react-server-dom-webpack-server.browser.development.js +349 -56
  19. package/cjs/react-server-dom-webpack-server.browser.production.js +93 -36
  20. package/cjs/react-server-dom-webpack-server.browser.production.min.js +68 -68
  21. package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
  22. package/cjs/react-server-dom-webpack-server.edge.development.js +349 -56
  23. package/cjs/react-server-dom-webpack-server.edge.production.js +93 -36
  24. package/cjs/react-server-dom-webpack-server.edge.production.min.js +58 -58
  25. package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
  26. package/cjs/react-server-dom-webpack-server.node.development.js +349 -56
  27. package/cjs/react-server-dom-webpack-server.node.production.js +93 -36
  28. package/cjs/react-server-dom-webpack-server.node.production.min.js +56 -56
  29. package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -1
  30. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +349 -56
  31. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +93 -36
  32. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +53 -53
  33. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
  34. package/package.json +3 -3
  35. package/umd/react-server-dom-webpack-client.browser.development.js +136 -97
  36. package/umd/react-server-dom-webpack-client.browser.production.min.js +25 -25
  37. package/umd/react-server-dom-webpack-server.browser.development.js +349 -56
  38. package/umd/react-server-dom-webpack-server.browser.production.min.js +54 -54
@@ -17,7 +17,12 @@ if (process.env.NODE_ENV !== "production") {
17
17
  var React = require('react');
18
18
  var ReactDOM = require('react-dom');
19
19
 
20
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
20
+ var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
21
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
22
+
23
+ if (!ReactSharedInternalsServer) {
24
+ 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.');
25
+ }
21
26
 
22
27
  function error(format) {
23
28
  {
@@ -35,8 +40,7 @@ function printWarning(level, format, args) {
35
40
  // When changing this logic, you might want to also
36
41
  // update consoleWithStackDev.www.js as well.
37
42
  {
38
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
39
- var stack = ReactDebugCurrentFrame.getStackAddendum();
43
+ var stack = ReactSharedInternalsServer.getStackAddendum();
40
44
 
41
45
  if (stack !== '') {
42
46
  format += '%s';
@@ -453,18 +457,45 @@ function getServerReferenceBoundArguments(config, serverReference) {
453
457
  return serverReference.$$bound;
454
458
  }
455
459
 
456
- var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
457
-
458
- var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
459
- var previousDispatcher = ReactDOMCurrentDispatcher.current;
460
- ReactDOMCurrentDispatcher.current = {
461
- prefetchDNS: prefetchDNS,
462
- preconnect: preconnect,
463
- preload: preload,
464
- preloadModule: preloadModule$1,
465
- preinitStyle: preinitStyle,
466
- preinitScript: preinitScript,
467
- preinitModuleScript: preinitModuleScript
460
+ var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
461
+
462
+ var previousDispatcher = ReactDOMSharedInternals.d;
463
+ /* ReactDOMCurrentDispatcher */
464
+
465
+ ReactDOMSharedInternals.d
466
+ /* ReactDOMCurrentDispatcher */
467
+ = {
468
+ f
469
+ /* flushSyncWork */
470
+ : previousDispatcher.f
471
+ /* flushSyncWork */
472
+ ,
473
+ r
474
+ /* requestFormReset */
475
+ : previousDispatcher.r
476
+ /* requestFormReset */
477
+ ,
478
+ D
479
+ /* prefetchDNS */
480
+ : prefetchDNS,
481
+ C
482
+ /* preconnect */
483
+ : preconnect,
484
+ L
485
+ /* preload */
486
+ : preload,
487
+ m
488
+ /* preloadModule */
489
+ : preloadModule$1,
490
+ X
491
+ /* preinitScript */
492
+ : preinitScript,
493
+ S
494
+ /* preinitStyle */
495
+ : preinitStyle,
496
+ M
497
+ /* preinitModuleScript */
498
+ : preinitModuleScript
468
499
  };
469
500
 
470
501
  function prefetchDNS(href) {
@@ -483,7 +514,9 @@ function prefetchDNS(href) {
483
514
  hints.add(key);
484
515
  emitHint(request, 'D', href);
485
516
  } else {
486
- previousDispatcher.prefetchDNS(href);
517
+ previousDispatcher.D(
518
+ /* prefetchDNS */
519
+ href);
487
520
  }
488
521
  }
489
522
  }
@@ -509,7 +542,9 @@ function preconnect(href, crossOrigin) {
509
542
  emitHint(request, 'C', href);
510
543
  }
511
544
  } else {
512
- previousDispatcher.preconnect(href, crossOrigin);
545
+ previousDispatcher.C(
546
+ /* preconnect */
547
+ href, crossOrigin);
513
548
  }
514
549
  }
515
550
  }
@@ -542,7 +577,9 @@ function preload(href, as, options) {
542
577
  emitHint(request, 'L', [href, as]);
543
578
  }
544
579
  } else {
545
- previousDispatcher.preload(href, as, options);
580
+ previousDispatcher.L(
581
+ /* preload */
582
+ href, as, options);
546
583
  }
547
584
  }
548
585
  }
@@ -569,7 +606,9 @@ function preloadModule$1(href, options) {
569
606
  return emitHint(request, 'm', href);
570
607
  }
571
608
  } else {
572
- previousDispatcher.preloadModule(href, options);
609
+ previousDispatcher.m(
610
+ /* preloadModule */
611
+ href, options);
573
612
  }
574
613
  }
575
614
  }
@@ -598,7 +637,9 @@ function preinitStyle(href, precedence, options) {
598
637
  return emitHint(request, 'S', href);
599
638
  }
600
639
  } else {
601
- previousDispatcher.preinitStyle(href, precedence, options);
640
+ previousDispatcher.S(
641
+ /* preinitStyle */
642
+ href, precedence, options);
602
643
  }
603
644
  }
604
645
  }
@@ -625,7 +666,9 @@ function preinitScript(src, options) {
625
666
  return emitHint(request, 'X', src);
626
667
  }
627
668
  } else {
628
- previousDispatcher.preinitScript(src, options);
669
+ previousDispatcher.X(
670
+ /* preinitScript */
671
+ src, options);
629
672
  }
630
673
  }
631
674
  }
@@ -652,7 +695,9 @@ function preinitModuleScript(src, options) {
652
695
  return emitHint(request, 'M', src);
653
696
  }
654
697
  } else {
655
- previousDispatcher.preinitModuleScript(src, options);
698
+ previousDispatcher.M(
699
+ /* preinitModuleScript */
700
+ src, options);
656
701
  }
657
702
  }
658
703
  } // Flight normally encodes undefined as a special character however for directive option
@@ -925,21 +970,34 @@ function getSuspendedThenable() {
925
970
  var currentRequest$1 = null;
926
971
  var thenableIndexCounter = 0;
927
972
  var thenableState = null;
973
+ var currentComponentDebugInfo = null;
928
974
  function prepareToUseHooksForRequest(request) {
929
975
  currentRequest$1 = request;
930
976
  }
931
977
  function resetHooksForRequest() {
932
978
  currentRequest$1 = null;
933
979
  }
934
- function prepareToUseHooksForComponent(prevThenableState) {
980
+ function prepareToUseHooksForComponent(prevThenableState, componentDebugInfo) {
935
981
  thenableIndexCounter = 0;
936
982
  thenableState = prevThenableState;
983
+
984
+ {
985
+ currentComponentDebugInfo = componentDebugInfo;
986
+ }
937
987
  }
938
988
  function getThenableStateAfterSuspending() {
939
989
  // If you use() to Suspend this should always exist but if you throw a Promise instead,
940
990
  // which is not really supported anymore, it will be empty. We use the empty set as a
941
991
  // marker to know if this was a replay of the same component or first attempt.
942
992
  var state = thenableState || createThenableState();
993
+
994
+ {
995
+ // This is a hack but we stash the debug info here so that we don't need a completely
996
+ // different data structure just for this in DEV. Not too happy about it.
997
+ state._componentDebugInfo = currentComponentDebugInfo;
998
+ currentComponentDebugInfo = null;
999
+ }
1000
+
943
1001
  thenableState = null;
944
1002
  return state;
945
1003
  }
@@ -1397,12 +1455,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1397
1455
  return '\n ' + str;
1398
1456
  }
1399
1457
 
1400
- var ReactSharedServerInternals = // $FlowFixMe: It's defined in the one we resolve to.
1401
- React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1402
-
1403
- if (!ReactSharedServerInternals) {
1404
- 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.');
1405
- }
1458
+ var ReactSharedInternals = ReactSharedInternalsServer;
1406
1459
 
1407
1460
  var ObjectPrototype = Object.prototype;
1408
1461
  var stringify = JSON.stringify; // Serializable values
@@ -1416,8 +1469,6 @@ var ERRORED$1 = 4; // object reference status
1416
1469
 
1417
1470
  var SEEN_BUT_NOT_YET_OUTLINED = -1;
1418
1471
  var NEVER_OUTLINED = -2;
1419
- var ReactCurrentCache = ReactSharedServerInternals.ReactCurrentCache;
1420
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
1421
1472
 
1422
1473
  function defaultErrorHandler(error) {
1423
1474
  console['error'](error); // Don't transform to our wrapper
@@ -1430,11 +1481,11 @@ var OPEN = 0;
1430
1481
  var CLOSING = 1;
1431
1482
  var CLOSED = 2;
1432
1483
  function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
1433
- if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
1484
+ if (ReactSharedInternals.C !== null && ReactSharedInternals.C !== DefaultCacheDispatcher) {
1434
1485
  throw new Error('Currently React only supports one RSC renderer at a time.');
1435
1486
  }
1436
1487
 
1437
- ReactCurrentCache.current = DefaultCacheDispatcher;
1488
+ ReactSharedInternals.C = DefaultCacheDispatcher;
1438
1489
  var abortSet = new Set();
1439
1490
  var pingedTasks = [];
1440
1491
  var cleanupQueue = [];
@@ -1638,33 +1689,56 @@ function createLazyWrapperAroundWakeable(wakeable) {
1638
1689
  return lazyType;
1639
1690
  }
1640
1691
 
1641
- function renderFunctionComponent(request, task, key, Component, props) {
1692
+ function renderFunctionComponent(request, task, key, Component, props, owner) {
1642
1693
  // Reset the task's thenable state before continuing, so that if a later
1643
1694
  // component suspends we can reuse the same task object. If the same
1644
1695
  // component suspends again, the thenable state will be restored.
1645
1696
  var prevThenableState = task.thenableState;
1646
1697
  task.thenableState = null;
1698
+ var componentDebugInfo = null;
1647
1699
 
1648
1700
  {
1649
1701
  if (debugID === null) {
1650
1702
  // We don't have a chunk to assign debug info. We need to outline this
1651
1703
  // component to assign it an ID.
1652
1704
  return outlineTask(request, task);
1653
- } else if (prevThenableState !== null) ; else {
1705
+ } else if (prevThenableState !== null) {
1706
+ // This is a replay and we've already emitted the debug info of this component
1707
+ // in the first pass. We skip emitting a duplicate line.
1708
+ // As a hack we stashed the previous component debug info on this object in DEV.
1709
+ componentDebugInfo = prevThenableState._componentDebugInfo;
1710
+ } else {
1654
1711
  // This is a new component in the same task so we can emit more debug info.
1655
1712
  var componentName = Component.displayName || Component.name || '';
1656
1713
  request.pendingChunks++;
1657
- emitDebugChunk(request, debugID, {
1714
+ var componentDebugID = debugID;
1715
+ componentDebugInfo = {
1658
1716
  name: componentName,
1659
- env: request.environmentName
1660
- });
1717
+ env: request.environmentName,
1718
+ owner: owner
1719
+ }; // We outline this model eagerly so that we can refer to by reference as an owner.
1720
+ // If we had a smarter way to dedupe we might not have to do this if there ends up
1721
+ // being no references to this as an owner.
1722
+
1723
+ outlineModel(request, componentDebugInfo);
1724
+ emitDebugChunk(request, componentDebugID, componentDebugInfo);
1661
1725
  }
1662
1726
  }
1663
1727
 
1664
- prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
1728
+ prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); // The secondArg is always undefined in Server Components since refs error early.
1665
1729
 
1666
1730
  var secondArg = undefined;
1667
- var result = Component(props, secondArg);
1731
+ var result;
1732
+
1733
+ {
1734
+ ReactSharedInternals.owner = componentDebugInfo;
1735
+
1736
+ try {
1737
+ result = Component(props, secondArg);
1738
+ } finally {
1739
+ ReactSharedInternals.owner = null;
1740
+ }
1741
+ }
1668
1742
 
1669
1743
  if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1670
1744
  // When the return value is in children position we can resolve it immediately,
@@ -1755,7 +1829,8 @@ function renderFragment(request, task, children) {
1755
1829
  return children;
1756
1830
  }
1757
1831
 
1758
- function renderClientElement(task, type, key, props) {
1832
+ function renderClientElement(task, type, key, props, owner) // DEV-only
1833
+ {
1759
1834
  // the keys of any Server Components which are not serialized.
1760
1835
 
1761
1836
 
@@ -1767,7 +1842,7 @@ function renderClientElement(task, type, key, props) {
1767
1842
  key = keyPath + ',' + key;
1768
1843
  }
1769
1844
 
1770
- var element = [REACT_ELEMENT_TYPE, type, key, props];
1845
+ var element = [REACT_ELEMENT_TYPE, type, key, props, owner] ;
1771
1846
 
1772
1847
  if (task.implicitSlot && key !== null) {
1773
1848
  // The root Server Component had no key so it was in an implicit slot.
@@ -1805,7 +1880,8 @@ function outlineTask(request, task) {
1805
1880
  return serializeLazyID(newTask.id);
1806
1881
  }
1807
1882
 
1808
- function renderElement(request, task, type, key, ref, props) {
1883
+ function renderElement(request, task, type, key, ref, props, owner) // DEV only
1884
+ {
1809
1885
  if (ref !== null && ref !== undefined) {
1810
1886
  // When the ref moves to the regular props object this will implicitly
1811
1887
  // throw for functions. We could probably relax it to a DEV warning for other
@@ -1826,14 +1902,14 @@ function renderElement(request, task, type, key, ref, props) {
1826
1902
  if (typeof type === 'function') {
1827
1903
  if (isClientReference(type) || isTemporaryReference(type)) {
1828
1904
  // This is a reference to a Client Component.
1829
- return renderClientElement(task, type, key, props);
1905
+ return renderClientElement(task, type, key, props, owner);
1830
1906
  } // This is a Server Component.
1831
1907
 
1832
1908
 
1833
- return renderFunctionComponent(request, task, key, type, props);
1909
+ return renderFunctionComponent(request, task, key, type, props, owner);
1834
1910
  } else if (typeof type === 'string') {
1835
1911
  // This is a host element. E.g. HTML.
1836
- return renderClientElement(task, type, key, props);
1912
+ return renderClientElement(task, type, key, props, owner);
1837
1913
  } else if (typeof type === 'symbol') {
1838
1914
  if (type === REACT_FRAGMENT_TYPE && key === null) {
1839
1915
  // For key-less fragments, we add a small optimization to avoid serializing
@@ -1851,11 +1927,11 @@ function renderElement(request, task, type, key, ref, props) {
1851
1927
  // Any built-in works as long as its props are serializable.
1852
1928
 
1853
1929
 
1854
- return renderClientElement(task, type, key, props);
1930
+ return renderClientElement(task, type, key, props, owner);
1855
1931
  } else if (type != null && typeof type === 'object') {
1856
1932
  if (isClientReference(type)) {
1857
1933
  // This is a reference to a Client Component.
1858
- return renderClientElement(task, type, key, props);
1934
+ return renderClientElement(task, type, key, props, owner);
1859
1935
  }
1860
1936
 
1861
1937
  switch (type.$$typeof) {
@@ -1864,17 +1940,17 @@ function renderElement(request, task, type, key, ref, props) {
1864
1940
  var payload = type._payload;
1865
1941
  var init = type._init;
1866
1942
  var wrappedType = init(payload);
1867
- return renderElement(request, task, wrappedType, key, ref, props);
1943
+ return renderElement(request, task, wrappedType, key, ref, props, owner);
1868
1944
  }
1869
1945
 
1870
1946
  case REACT_FORWARD_REF_TYPE:
1871
1947
  {
1872
- return renderFunctionComponent(request, task, key, type.render, props);
1948
+ return renderFunctionComponent(request, task, key, type.render, props, owner);
1873
1949
  }
1874
1950
 
1875
1951
  case REACT_MEMO_TYPE:
1876
1952
  {
1877
- return renderElement(request, task, type.type, key, ref, props);
1953
+ return renderElement(request, task, type.type, key, ref, props, owner);
1878
1954
  }
1879
1955
  }
1880
1956
  }
@@ -1953,6 +2029,10 @@ function serializeLazyID(id) {
1953
2029
  return '$L' + id.toString(16);
1954
2030
  }
1955
2031
 
2032
+ function serializeInfinitePromise() {
2033
+ return '$@';
2034
+ }
2035
+
1956
2036
  function serializePromiseID(id) {
1957
2037
  return '$@' + id.toString(16);
1958
2038
  }
@@ -2117,6 +2197,12 @@ function serializeMap(request, map) {
2117
2197
  return '$Q' + id.toString(16);
2118
2198
  }
2119
2199
 
2200
+ function serializeFormData(request, formData) {
2201
+ var entries = Array.from(formData.entries());
2202
+ var id = outlineModel(request, entries);
2203
+ return '$K' + id.toString(16);
2204
+ }
2205
+
2120
2206
  function serializeSet(request, set) {
2121
2207
  var entries = Array.from(set);
2122
2208
 
@@ -2293,7 +2379,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2293
2379
 
2294
2380
 
2295
2381
  return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
2296
- element.key, ref, props);
2382
+ element.key, ref, props, element._owner );
2297
2383
  }
2298
2384
 
2299
2385
  case REACT_LAZY_TYPE:
@@ -2391,6 +2477,11 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2391
2477
 
2392
2478
  if (value instanceof Set) {
2393
2479
  return serializeSet(request, value);
2480
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2481
+
2482
+
2483
+ if (typeof FormData === 'function' && value instanceof FormData) {
2484
+ return serializeFormData(request, value);
2394
2485
  }
2395
2486
 
2396
2487
  var iteratorFn = getIteratorFn(value);
@@ -2652,14 +2743,216 @@ function emitModelChunk(request, id, json) {
2652
2743
  }
2653
2744
 
2654
2745
  function emitDebugChunk(request, id, debugInfo) {
2746
+ // use the full serialization that requires a task.
2655
2747
 
2656
2748
 
2657
- var json = stringify(debugInfo);
2749
+ var counter = {
2750
+ objectCount: 0
2751
+ };
2752
+
2753
+ function replacer(parentPropertyName, value) {
2754
+ return renderConsoleValue(request, counter, this, parentPropertyName, value);
2755
+ } // $FlowFixMe[incompatible-type] stringify can return null
2756
+
2757
+
2758
+ var json = stringify(debugInfo, replacer);
2658
2759
  var row = serializeRowHeader('D', id) + json + '\n';
2659
2760
  var processedChunk = stringToChunk(row);
2660
2761
  request.completedRegularChunks.push(processedChunk);
2661
2762
  }
2662
2763
 
2764
+ function serializeEval(source) {
2765
+
2766
+ return '$E' + source;
2767
+ } // This is a forked version of renderModel which should never error, never suspend and is limited
2768
+ // in the depth it can encode.
2769
+
2770
+
2771
+ function renderConsoleValue(request, counter, parent, parentPropertyName, value) {
2772
+ // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
2773
+ // $FlowFixMe[incompatible-use]
2774
+ var originalValue = parent[parentPropertyName];
2775
+
2776
+ if (value === null) {
2777
+ return null;
2778
+ }
2779
+
2780
+ if (typeof value === 'object') {
2781
+ if (isClientReference(value)) {
2782
+ // We actually have this value on the client so we could import it.
2783
+ // This might be confusing though because on the Server it won't actually
2784
+ // be this value, so if you're debugging client references maybe you'd be
2785
+ // better with a place holder.
2786
+ return serializeClientReference(request, parent, parentPropertyName, value);
2787
+ }
2788
+
2789
+ if (counter.objectCount > 20) {
2790
+ // We've reached our max number of objects to serialize across the wire so we serialize this
2791
+ // object but no properties inside of it, as a place holder.
2792
+ return Array.isArray(value) ? [] : {};
2793
+ }
2794
+
2795
+ counter.objectCount++;
2796
+ var writtenObjects = request.writtenObjects;
2797
+ var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
2798
+
2799
+ if (typeof value.then === 'function') {
2800
+ if (existingId !== undefined) {
2801
+ // We've seen this promise before, so we can just refer to the same result.
2802
+ return serializePromiseID(existingId);
2803
+ }
2804
+
2805
+ var thenable = value;
2806
+
2807
+ switch (thenable.status) {
2808
+ case 'fulfilled':
2809
+ {
2810
+ return serializePromiseID(outlineConsoleValue(request, counter, thenable.value));
2811
+ }
2812
+
2813
+ case 'rejected':
2814
+ {
2815
+ var x = thenable.reason;
2816
+ request.pendingChunks++;
2817
+ var errorId = request.nextChunkId++;
2818
+
2819
+ {
2820
+ // We don't log these errors since they didn't actually throw into Flight.
2821
+ var digest = '';
2822
+ emitErrorChunk(request, errorId, digest, x);
2823
+ }
2824
+
2825
+ return serializePromiseID(errorId);
2826
+ }
2827
+ } // If it hasn't already resolved (and been instrumented) we just encode an infinite
2828
+ // promise that will never resolve.
2829
+
2830
+
2831
+ return serializeInfinitePromise();
2832
+ }
2833
+
2834
+ if (existingId !== undefined && existingId >= 0) {
2835
+ // We've already emitted this as a real object, so we can
2836
+ // just refer to that by its existing ID.
2837
+ return serializeByValueID(existingId);
2838
+ }
2839
+
2840
+ if (isArray(value)) {
2841
+ return value;
2842
+ }
2843
+
2844
+ if (value instanceof Map) {
2845
+ return serializeMap(request, value);
2846
+ }
2847
+
2848
+ if (value instanceof Set) {
2849
+ return serializeSet(request, value);
2850
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2851
+
2852
+
2853
+ if (typeof FormData === 'function' && value instanceof FormData) {
2854
+ return serializeFormData(request, value);
2855
+ }
2856
+
2857
+ var iteratorFn = getIteratorFn(value);
2858
+
2859
+ if (iteratorFn) {
2860
+ return Array.from(value);
2861
+ } // $FlowFixMe[incompatible-return]
2862
+
2863
+
2864
+ return value;
2865
+ }
2866
+
2867
+ if (typeof value === 'string') {
2868
+ if (value[value.length - 1] === 'Z') {
2869
+ // Possibly a Date, whose toJSON automatically calls toISOString
2870
+ if (originalValue instanceof Date) {
2871
+ return serializeDateFromDateJSON(value);
2872
+ }
2873
+ }
2874
+
2875
+ if (value.length >= 1024) {
2876
+ // For large strings, we encode them outside the JSON payload so that we
2877
+ // don't have to double encode and double parse the strings. This can also
2878
+ // be more compact in case the string has a lot of escaped characters.
2879
+ return serializeLargeTextString(request, value);
2880
+ }
2881
+
2882
+ return escapeStringValue(value);
2883
+ }
2884
+
2885
+ if (typeof value === 'boolean') {
2886
+ return value;
2887
+ }
2888
+
2889
+ if (typeof value === 'number') {
2890
+ return serializeNumber(value);
2891
+ }
2892
+
2893
+ if (typeof value === 'undefined') {
2894
+ return serializeUndefined();
2895
+ }
2896
+
2897
+ if (typeof value === 'function') {
2898
+ if (isClientReference(value)) {
2899
+ return serializeClientReference(request, parent, parentPropertyName, value);
2900
+ }
2901
+
2902
+ if (isTemporaryReference(value)) {
2903
+ return serializeTemporaryReference(request, value);
2904
+ } // Serialize the body of the function as an eval so it can be printed.
2905
+ // $FlowFixMe[method-unbinding]
2906
+
2907
+
2908
+ return serializeEval('(' + Function.prototype.toString.call(value) + ')');
2909
+ }
2910
+
2911
+ if (typeof value === 'symbol') {
2912
+ var writtenSymbols = request.writtenSymbols;
2913
+
2914
+ var _existingId3 = writtenSymbols.get(value);
2915
+
2916
+ if (_existingId3 !== undefined) {
2917
+ return serializeByValueID(_existingId3);
2918
+ } // $FlowFixMe[incompatible-type] `description` might be undefined
2919
+
2920
+
2921
+ var name = value.description; // We use the Symbol.for version if it's not a global symbol. Close enough.
2922
+
2923
+ request.pendingChunks++;
2924
+ var symbolId = request.nextChunkId++;
2925
+ emitSymbolChunk(request, symbolId, name);
2926
+ return serializeByValueID(symbolId);
2927
+ }
2928
+
2929
+ if (typeof value === 'bigint') {
2930
+ return serializeBigInt(value);
2931
+ }
2932
+
2933
+ return 'unknown type ' + typeof value;
2934
+ }
2935
+
2936
+ function outlineConsoleValue(request, counter, model) {
2937
+
2938
+ function replacer(parentPropertyName, value) {
2939
+ try {
2940
+ return renderConsoleValue(request, counter, this, parentPropertyName, value);
2941
+ } catch (x) {
2942
+ return 'unknown value';
2943
+ }
2944
+ } // $FlowFixMe[incompatible-type] stringify can return null
2945
+
2946
+
2947
+ var json = stringify(model, replacer);
2948
+ request.pendingChunks++;
2949
+ var id = request.nextChunkId++;
2950
+ var row = id.toString(16) + ':' + json + '\n';
2951
+ var processedChunk = stringToChunk(row);
2952
+ request.completedRegularChunks.push(processedChunk);
2953
+ return id;
2954
+ }
2955
+
2663
2956
  function forwardDebugInfo(request, id, debugInfo) {
2664
2957
  for (var i = 0; i < debugInfo.length; i++) {
2665
2958
  request.pendingChunks++;
@@ -2751,8 +3044,8 @@ function retryTask(request, task) {
2751
3044
  }
2752
3045
 
2753
3046
  function performWork(request) {
2754
- var prevDispatcher = ReactCurrentDispatcher.current;
2755
- ReactCurrentDispatcher.current = HooksDispatcher;
3047
+ var prevDispatcher = ReactSharedInternals.H;
3048
+ ReactSharedInternals.H = HooksDispatcher;
2756
3049
  var prevRequest = currentRequest;
2757
3050
  currentRequest = request;
2758
3051
  prepareToUseHooksForRequest(request);
@@ -2773,7 +3066,7 @@ function performWork(request) {
2773
3066
  logRecoverableError(request, error);
2774
3067
  fatalError(request, error);
2775
3068
  } finally {
2776
- ReactCurrentDispatcher.current = prevDispatcher;
3069
+ ReactSharedInternals.H = prevDispatcher;
2777
3070
  resetHooksForRequest();
2778
3071
  currentRequest = prevRequest;
2779
3072
  }