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
@@ -20,7 +20,12 @@ require('crypto');
20
20
  var async_hooks = require('async_hooks');
21
21
  var ReactDOM = require('react-dom');
22
22
 
23
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
23
+ var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
24
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
25
+
26
+ if (!ReactSharedInternalsServer) {
27
+ 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.');
28
+ }
24
29
 
25
30
  function error(format) {
26
31
  {
@@ -38,8 +43,7 @@ function printWarning(level, format, args) {
38
43
  // When changing this logic, you might want to also
39
44
  // update consoleWithStackDev.www.js as well.
40
45
  {
41
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
42
- var stack = ReactDebugCurrentFrame.getStackAddendum();
46
+ var stack = ReactSharedInternalsServer.getStackAddendum();
43
47
 
44
48
  if (stack !== '') {
45
49
  format += '%s';
@@ -520,18 +524,45 @@ function getServerReferenceBoundArguments(config, serverReference) {
520
524
  return serverReference.$$bound;
521
525
  }
522
526
 
523
- var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
524
-
525
- var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
526
- var previousDispatcher = ReactDOMCurrentDispatcher.current;
527
- ReactDOMCurrentDispatcher.current = {
528
- prefetchDNS: prefetchDNS,
529
- preconnect: preconnect,
530
- preload: preload,
531
- preloadModule: preloadModule$1,
532
- preinitStyle: preinitStyle,
533
- preinitScript: preinitScript,
534
- preinitModuleScript: preinitModuleScript
527
+ var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
528
+
529
+ var previousDispatcher = ReactDOMSharedInternals.d;
530
+ /* ReactDOMCurrentDispatcher */
531
+
532
+ ReactDOMSharedInternals.d
533
+ /* ReactDOMCurrentDispatcher */
534
+ = {
535
+ f
536
+ /* flushSyncWork */
537
+ : previousDispatcher.f
538
+ /* flushSyncWork */
539
+ ,
540
+ r
541
+ /* requestFormReset */
542
+ : previousDispatcher.r
543
+ /* requestFormReset */
544
+ ,
545
+ D
546
+ /* prefetchDNS */
547
+ : prefetchDNS,
548
+ C
549
+ /* preconnect */
550
+ : preconnect,
551
+ L
552
+ /* preload */
553
+ : preload,
554
+ m
555
+ /* preloadModule */
556
+ : preloadModule$1,
557
+ X
558
+ /* preinitScript */
559
+ : preinitScript,
560
+ S
561
+ /* preinitStyle */
562
+ : preinitStyle,
563
+ M
564
+ /* preinitModuleScript */
565
+ : preinitModuleScript
535
566
  };
536
567
 
537
568
  function prefetchDNS(href) {
@@ -550,7 +581,9 @@ function prefetchDNS(href) {
550
581
  hints.add(key);
551
582
  emitHint(request, 'D', href);
552
583
  } else {
553
- previousDispatcher.prefetchDNS(href);
584
+ previousDispatcher.D(
585
+ /* prefetchDNS */
586
+ href);
554
587
  }
555
588
  }
556
589
  }
@@ -576,7 +609,9 @@ function preconnect(href, crossOrigin) {
576
609
  emitHint(request, 'C', href);
577
610
  }
578
611
  } else {
579
- previousDispatcher.preconnect(href, crossOrigin);
612
+ previousDispatcher.C(
613
+ /* preconnect */
614
+ href, crossOrigin);
580
615
  }
581
616
  }
582
617
  }
@@ -609,7 +644,9 @@ function preload(href, as, options) {
609
644
  emitHint(request, 'L', [href, as]);
610
645
  }
611
646
  } else {
612
- previousDispatcher.preload(href, as, options);
647
+ previousDispatcher.L(
648
+ /* preload */
649
+ href, as, options);
613
650
  }
614
651
  }
615
652
  }
@@ -636,7 +673,9 @@ function preloadModule$1(href, options) {
636
673
  return emitHint(request, 'm', href);
637
674
  }
638
675
  } else {
639
- previousDispatcher.preloadModule(href, options);
676
+ previousDispatcher.m(
677
+ /* preloadModule */
678
+ href, options);
640
679
  }
641
680
  }
642
681
  }
@@ -665,7 +704,9 @@ function preinitStyle(href, precedence, options) {
665
704
  return emitHint(request, 'S', href);
666
705
  }
667
706
  } else {
668
- previousDispatcher.preinitStyle(href, precedence, options);
707
+ previousDispatcher.S(
708
+ /* preinitStyle */
709
+ href, precedence, options);
669
710
  }
670
711
  }
671
712
  }
@@ -692,7 +733,9 @@ function preinitScript(src, options) {
692
733
  return emitHint(request, 'X', src);
693
734
  }
694
735
  } else {
695
- previousDispatcher.preinitScript(src, options);
736
+ previousDispatcher.X(
737
+ /* preinitScript */
738
+ src, options);
696
739
  }
697
740
  }
698
741
  }
@@ -719,7 +762,9 @@ function preinitModuleScript(src, options) {
719
762
  return emitHint(request, 'M', src);
720
763
  }
721
764
  } else {
722
- previousDispatcher.preinitModuleScript(src, options);
765
+ previousDispatcher.M(
766
+ /* preinitModuleScript */
767
+ src, options);
723
768
  }
724
769
  }
725
770
  } // Flight normally encodes undefined as a special character however for directive option
@@ -992,21 +1037,34 @@ function getSuspendedThenable() {
992
1037
  var currentRequest$1 = null;
993
1038
  var thenableIndexCounter = 0;
994
1039
  var thenableState = null;
1040
+ var currentComponentDebugInfo = null;
995
1041
  function prepareToUseHooksForRequest(request) {
996
1042
  currentRequest$1 = request;
997
1043
  }
998
1044
  function resetHooksForRequest() {
999
1045
  currentRequest$1 = null;
1000
1046
  }
1001
- function prepareToUseHooksForComponent(prevThenableState) {
1047
+ function prepareToUseHooksForComponent(prevThenableState, componentDebugInfo) {
1002
1048
  thenableIndexCounter = 0;
1003
1049
  thenableState = prevThenableState;
1050
+
1051
+ {
1052
+ currentComponentDebugInfo = componentDebugInfo;
1053
+ }
1004
1054
  }
1005
1055
  function getThenableStateAfterSuspending() {
1006
1056
  // If you use() to Suspend this should always exist but if you throw a Promise instead,
1007
1057
  // which is not really supported anymore, it will be empty. We use the empty set as a
1008
1058
  // marker to know if this was a replay of the same component or first attempt.
1009
1059
  var state = thenableState || createThenableState();
1060
+
1061
+ {
1062
+ // This is a hack but we stash the debug info here so that we don't need a completely
1063
+ // different data structure just for this in DEV. Not too happy about it.
1064
+ state._componentDebugInfo = currentComponentDebugInfo;
1065
+ currentComponentDebugInfo = null;
1066
+ }
1067
+
1010
1068
  thenableState = null;
1011
1069
  return state;
1012
1070
  }
@@ -1464,12 +1522,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1464
1522
  return '\n ' + str;
1465
1523
  }
1466
1524
 
1467
- var ReactSharedServerInternals = // $FlowFixMe: It's defined in the one we resolve to.
1468
- React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1469
-
1470
- if (!ReactSharedServerInternals) {
1471
- 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.');
1472
- }
1525
+ var ReactSharedInternals = ReactSharedInternalsServer;
1473
1526
 
1474
1527
  var ObjectPrototype = Object.prototype;
1475
1528
  var stringify = JSON.stringify; // Serializable values
@@ -1483,8 +1536,6 @@ var ERRORED$1 = 4; // object reference status
1483
1536
 
1484
1537
  var SEEN_BUT_NOT_YET_OUTLINED = -1;
1485
1538
  var NEVER_OUTLINED = -2;
1486
- var ReactCurrentCache = ReactSharedServerInternals.ReactCurrentCache;
1487
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
1488
1539
 
1489
1540
  function defaultErrorHandler(error) {
1490
1541
  console['error'](error); // Don't transform to our wrapper
@@ -1497,11 +1548,11 @@ var OPEN = 0;
1497
1548
  var CLOSING = 1;
1498
1549
  var CLOSED = 2;
1499
1550
  function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
1500
- if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
1551
+ if (ReactSharedInternals.C !== null && ReactSharedInternals.C !== DefaultCacheDispatcher) {
1501
1552
  throw new Error('Currently React only supports one RSC renderer at a time.');
1502
1553
  }
1503
1554
 
1504
- ReactCurrentCache.current = DefaultCacheDispatcher;
1555
+ ReactSharedInternals.C = DefaultCacheDispatcher;
1505
1556
  var abortSet = new Set();
1506
1557
  var pingedTasks = [];
1507
1558
  var cleanupQueue = [];
@@ -1710,33 +1761,56 @@ function createLazyWrapperAroundWakeable(wakeable) {
1710
1761
  return lazyType;
1711
1762
  }
1712
1763
 
1713
- function renderFunctionComponent(request, task, key, Component, props) {
1764
+ function renderFunctionComponent(request, task, key, Component, props, owner) {
1714
1765
  // Reset the task's thenable state before continuing, so that if a later
1715
1766
  // component suspends we can reuse the same task object. If the same
1716
1767
  // component suspends again, the thenable state will be restored.
1717
1768
  var prevThenableState = task.thenableState;
1718
1769
  task.thenableState = null;
1770
+ var componentDebugInfo = null;
1719
1771
 
1720
1772
  {
1721
1773
  if (debugID === null) {
1722
1774
  // We don't have a chunk to assign debug info. We need to outline this
1723
1775
  // component to assign it an ID.
1724
1776
  return outlineTask(request, task);
1725
- } else if (prevThenableState !== null) ; else {
1777
+ } else if (prevThenableState !== null) {
1778
+ // This is a replay and we've already emitted the debug info of this component
1779
+ // in the first pass. We skip emitting a duplicate line.
1780
+ // As a hack we stashed the previous component debug info on this object in DEV.
1781
+ componentDebugInfo = prevThenableState._componentDebugInfo;
1782
+ } else {
1726
1783
  // This is a new component in the same task so we can emit more debug info.
1727
1784
  var componentName = Component.displayName || Component.name || '';
1728
1785
  request.pendingChunks++;
1729
- emitDebugChunk(request, debugID, {
1786
+ var componentDebugID = debugID;
1787
+ componentDebugInfo = {
1730
1788
  name: componentName,
1731
- env: request.environmentName
1732
- });
1789
+ env: request.environmentName,
1790
+ owner: owner
1791
+ }; // We outline this model eagerly so that we can refer to by reference as an owner.
1792
+ // If we had a smarter way to dedupe we might not have to do this if there ends up
1793
+ // being no references to this as an owner.
1794
+
1795
+ outlineModel(request, componentDebugInfo);
1796
+ emitDebugChunk(request, componentDebugID, componentDebugInfo);
1733
1797
  }
1734
1798
  }
1735
1799
 
1736
- prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
1800
+ prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); // The secondArg is always undefined in Server Components since refs error early.
1737
1801
 
1738
1802
  var secondArg = undefined;
1739
- var result = Component(props, secondArg);
1803
+ var result;
1804
+
1805
+ {
1806
+ ReactSharedInternals.owner = componentDebugInfo;
1807
+
1808
+ try {
1809
+ result = Component(props, secondArg);
1810
+ } finally {
1811
+ ReactSharedInternals.owner = null;
1812
+ }
1813
+ }
1740
1814
 
1741
1815
  if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1742
1816
  // When the return value is in children position we can resolve it immediately,
@@ -1827,7 +1901,8 @@ function renderFragment(request, task, children) {
1827
1901
  return children;
1828
1902
  }
1829
1903
 
1830
- function renderClientElement(task, type, key, props) {
1904
+ function renderClientElement(task, type, key, props, owner) // DEV-only
1905
+ {
1831
1906
  // the keys of any Server Components which are not serialized.
1832
1907
 
1833
1908
 
@@ -1839,7 +1914,7 @@ function renderClientElement(task, type, key, props) {
1839
1914
  key = keyPath + ',' + key;
1840
1915
  }
1841
1916
 
1842
- var element = [REACT_ELEMENT_TYPE, type, key, props];
1917
+ var element = [REACT_ELEMENT_TYPE, type, key, props, owner] ;
1843
1918
 
1844
1919
  if (task.implicitSlot && key !== null) {
1845
1920
  // The root Server Component had no key so it was in an implicit slot.
@@ -1877,7 +1952,8 @@ function outlineTask(request, task) {
1877
1952
  return serializeLazyID(newTask.id);
1878
1953
  }
1879
1954
 
1880
- function renderElement(request, task, type, key, ref, props) {
1955
+ function renderElement(request, task, type, key, ref, props, owner) // DEV only
1956
+ {
1881
1957
  if (ref !== null && ref !== undefined) {
1882
1958
  // When the ref moves to the regular props object this will implicitly
1883
1959
  // throw for functions. We could probably relax it to a DEV warning for other
@@ -1898,14 +1974,14 @@ function renderElement(request, task, type, key, ref, props) {
1898
1974
  if (typeof type === 'function') {
1899
1975
  if (isClientReference(type) || isTemporaryReference(type)) {
1900
1976
  // This is a reference to a Client Component.
1901
- return renderClientElement(task, type, key, props);
1977
+ return renderClientElement(task, type, key, props, owner);
1902
1978
  } // This is a Server Component.
1903
1979
 
1904
1980
 
1905
- return renderFunctionComponent(request, task, key, type, props);
1981
+ return renderFunctionComponent(request, task, key, type, props, owner);
1906
1982
  } else if (typeof type === 'string') {
1907
1983
  // This is a host element. E.g. HTML.
1908
- return renderClientElement(task, type, key, props);
1984
+ return renderClientElement(task, type, key, props, owner);
1909
1985
  } else if (typeof type === 'symbol') {
1910
1986
  if (type === REACT_FRAGMENT_TYPE && key === null) {
1911
1987
  // For key-less fragments, we add a small optimization to avoid serializing
@@ -1923,11 +1999,11 @@ function renderElement(request, task, type, key, ref, props) {
1923
1999
  // Any built-in works as long as its props are serializable.
1924
2000
 
1925
2001
 
1926
- return renderClientElement(task, type, key, props);
2002
+ return renderClientElement(task, type, key, props, owner);
1927
2003
  } else if (type != null && typeof type === 'object') {
1928
2004
  if (isClientReference(type)) {
1929
2005
  // This is a reference to a Client Component.
1930
- return renderClientElement(task, type, key, props);
2006
+ return renderClientElement(task, type, key, props, owner);
1931
2007
  }
1932
2008
 
1933
2009
  switch (type.$$typeof) {
@@ -1936,17 +2012,17 @@ function renderElement(request, task, type, key, ref, props) {
1936
2012
  var payload = type._payload;
1937
2013
  var init = type._init;
1938
2014
  var wrappedType = init(payload);
1939
- return renderElement(request, task, wrappedType, key, ref, props);
2015
+ return renderElement(request, task, wrappedType, key, ref, props, owner);
1940
2016
  }
1941
2017
 
1942
2018
  case REACT_FORWARD_REF_TYPE:
1943
2019
  {
1944
- return renderFunctionComponent(request, task, key, type.render, props);
2020
+ return renderFunctionComponent(request, task, key, type.render, props, owner);
1945
2021
  }
1946
2022
 
1947
2023
  case REACT_MEMO_TYPE:
1948
2024
  {
1949
- return renderElement(request, task, type.type, key, ref, props);
2025
+ return renderElement(request, task, type.type, key, ref, props, owner);
1950
2026
  }
1951
2027
  }
1952
2028
  }
@@ -2025,6 +2101,10 @@ function serializeLazyID(id) {
2025
2101
  return '$L' + id.toString(16);
2026
2102
  }
2027
2103
 
2104
+ function serializeInfinitePromise() {
2105
+ return '$@';
2106
+ }
2107
+
2028
2108
  function serializePromiseID(id) {
2029
2109
  return '$@' + id.toString(16);
2030
2110
  }
@@ -2189,6 +2269,12 @@ function serializeMap(request, map) {
2189
2269
  return '$Q' + id.toString(16);
2190
2270
  }
2191
2271
 
2272
+ function serializeFormData(request, formData) {
2273
+ var entries = Array.from(formData.entries());
2274
+ var id = outlineModel(request, entries);
2275
+ return '$K' + id.toString(16);
2276
+ }
2277
+
2192
2278
  function serializeSet(request, set) {
2193
2279
  var entries = Array.from(set);
2194
2280
 
@@ -2365,7 +2451,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2365
2451
 
2366
2452
 
2367
2453
  return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
2368
- element.key, ref, props);
2454
+ element.key, ref, props, element._owner );
2369
2455
  }
2370
2456
 
2371
2457
  case REACT_LAZY_TYPE:
@@ -2463,6 +2549,11 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2463
2549
 
2464
2550
  if (value instanceof Set) {
2465
2551
  return serializeSet(request, value);
2552
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2553
+
2554
+
2555
+ if (typeof FormData === 'function' && value instanceof FormData) {
2556
+ return serializeFormData(request, value);
2466
2557
  }
2467
2558
 
2468
2559
  var iteratorFn = getIteratorFn(value);
@@ -2726,14 +2817,216 @@ function emitModelChunk(request, id, json) {
2726
2817
  }
2727
2818
 
2728
2819
  function emitDebugChunk(request, id, debugInfo) {
2820
+ // use the full serialization that requires a task.
2821
+
2822
+
2823
+ var counter = {
2824
+ objectCount: 0
2825
+ };
2729
2826
 
2827
+ function replacer(parentPropertyName, value) {
2828
+ return renderConsoleValue(request, counter, this, parentPropertyName, value);
2829
+ } // $FlowFixMe[incompatible-type] stringify can return null
2730
2830
 
2731
- var json = stringify(debugInfo);
2831
+
2832
+ var json = stringify(debugInfo, replacer);
2732
2833
  var row = serializeRowHeader('D', id) + json + '\n';
2733
2834
  var processedChunk = stringToChunk(row);
2734
2835
  request.completedRegularChunks.push(processedChunk);
2735
2836
  }
2736
2837
 
2838
+ function serializeEval(source) {
2839
+
2840
+ return '$E' + source;
2841
+ } // This is a forked version of renderModel which should never error, never suspend and is limited
2842
+ // in the depth it can encode.
2843
+
2844
+
2845
+ function renderConsoleValue(request, counter, parent, parentPropertyName, value) {
2846
+ // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
2847
+ // $FlowFixMe[incompatible-use]
2848
+ var originalValue = parent[parentPropertyName];
2849
+
2850
+ if (value === null) {
2851
+ return null;
2852
+ }
2853
+
2854
+ if (typeof value === 'object') {
2855
+ if (isClientReference(value)) {
2856
+ // We actually have this value on the client so we could import it.
2857
+ // This might be confusing though because on the Server it won't actually
2858
+ // be this value, so if you're debugging client references maybe you'd be
2859
+ // better with a place holder.
2860
+ return serializeClientReference(request, parent, parentPropertyName, value);
2861
+ }
2862
+
2863
+ if (counter.objectCount > 20) {
2864
+ // We've reached our max number of objects to serialize across the wire so we serialize this
2865
+ // object but no properties inside of it, as a place holder.
2866
+ return Array.isArray(value) ? [] : {};
2867
+ }
2868
+
2869
+ counter.objectCount++;
2870
+ var writtenObjects = request.writtenObjects;
2871
+ var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
2872
+
2873
+ if (typeof value.then === 'function') {
2874
+ if (existingId !== undefined) {
2875
+ // We've seen this promise before, so we can just refer to the same result.
2876
+ return serializePromiseID(existingId);
2877
+ }
2878
+
2879
+ var thenable = value;
2880
+
2881
+ switch (thenable.status) {
2882
+ case 'fulfilled':
2883
+ {
2884
+ return serializePromiseID(outlineConsoleValue(request, counter, thenable.value));
2885
+ }
2886
+
2887
+ case 'rejected':
2888
+ {
2889
+ var x = thenable.reason;
2890
+ request.pendingChunks++;
2891
+ var errorId = request.nextChunkId++;
2892
+
2893
+ {
2894
+ // We don't log these errors since they didn't actually throw into Flight.
2895
+ var digest = '';
2896
+ emitErrorChunk(request, errorId, digest, x);
2897
+ }
2898
+
2899
+ return serializePromiseID(errorId);
2900
+ }
2901
+ } // If it hasn't already resolved (and been instrumented) we just encode an infinite
2902
+ // promise that will never resolve.
2903
+
2904
+
2905
+ return serializeInfinitePromise();
2906
+ }
2907
+
2908
+ if (existingId !== undefined && existingId >= 0) {
2909
+ // We've already emitted this as a real object, so we can
2910
+ // just refer to that by its existing ID.
2911
+ return serializeByValueID(existingId);
2912
+ }
2913
+
2914
+ if (isArray(value)) {
2915
+ return value;
2916
+ }
2917
+
2918
+ if (value instanceof Map) {
2919
+ return serializeMap(request, value);
2920
+ }
2921
+
2922
+ if (value instanceof Set) {
2923
+ return serializeSet(request, value);
2924
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2925
+
2926
+
2927
+ if (typeof FormData === 'function' && value instanceof FormData) {
2928
+ return serializeFormData(request, value);
2929
+ }
2930
+
2931
+ var iteratorFn = getIteratorFn(value);
2932
+
2933
+ if (iteratorFn) {
2934
+ return Array.from(value);
2935
+ } // $FlowFixMe[incompatible-return]
2936
+
2937
+
2938
+ return value;
2939
+ }
2940
+
2941
+ if (typeof value === 'string') {
2942
+ if (value[value.length - 1] === 'Z') {
2943
+ // Possibly a Date, whose toJSON automatically calls toISOString
2944
+ if (originalValue instanceof Date) {
2945
+ return serializeDateFromDateJSON(value);
2946
+ }
2947
+ }
2948
+
2949
+ if (value.length >= 1024) {
2950
+ // For large strings, we encode them outside the JSON payload so that we
2951
+ // don't have to double encode and double parse the strings. This can also
2952
+ // be more compact in case the string has a lot of escaped characters.
2953
+ return serializeLargeTextString(request, value);
2954
+ }
2955
+
2956
+ return escapeStringValue(value);
2957
+ }
2958
+
2959
+ if (typeof value === 'boolean') {
2960
+ return value;
2961
+ }
2962
+
2963
+ if (typeof value === 'number') {
2964
+ return serializeNumber(value);
2965
+ }
2966
+
2967
+ if (typeof value === 'undefined') {
2968
+ return serializeUndefined();
2969
+ }
2970
+
2971
+ if (typeof value === 'function') {
2972
+ if (isClientReference(value)) {
2973
+ return serializeClientReference(request, parent, parentPropertyName, value);
2974
+ }
2975
+
2976
+ if (isTemporaryReference(value)) {
2977
+ return serializeTemporaryReference(request, value);
2978
+ } // Serialize the body of the function as an eval so it can be printed.
2979
+ // $FlowFixMe[method-unbinding]
2980
+
2981
+
2982
+ return serializeEval('(' + Function.prototype.toString.call(value) + ')');
2983
+ }
2984
+
2985
+ if (typeof value === 'symbol') {
2986
+ var writtenSymbols = request.writtenSymbols;
2987
+
2988
+ var _existingId3 = writtenSymbols.get(value);
2989
+
2990
+ if (_existingId3 !== undefined) {
2991
+ return serializeByValueID(_existingId3);
2992
+ } // $FlowFixMe[incompatible-type] `description` might be undefined
2993
+
2994
+
2995
+ var name = value.description; // We use the Symbol.for version if it's not a global symbol. Close enough.
2996
+
2997
+ request.pendingChunks++;
2998
+ var symbolId = request.nextChunkId++;
2999
+ emitSymbolChunk(request, symbolId, name);
3000
+ return serializeByValueID(symbolId);
3001
+ }
3002
+
3003
+ if (typeof value === 'bigint') {
3004
+ return serializeBigInt(value);
3005
+ }
3006
+
3007
+ return 'unknown type ' + typeof value;
3008
+ }
3009
+
3010
+ function outlineConsoleValue(request, counter, model) {
3011
+
3012
+ function replacer(parentPropertyName, value) {
3013
+ try {
3014
+ return renderConsoleValue(request, counter, this, parentPropertyName, value);
3015
+ } catch (x) {
3016
+ return 'unknown value';
3017
+ }
3018
+ } // $FlowFixMe[incompatible-type] stringify can return null
3019
+
3020
+
3021
+ var json = stringify(model, replacer);
3022
+ request.pendingChunks++;
3023
+ var id = request.nextChunkId++;
3024
+ var row = id.toString(16) + ':' + json + '\n';
3025
+ var processedChunk = stringToChunk(row);
3026
+ request.completedRegularChunks.push(processedChunk);
3027
+ return id;
3028
+ }
3029
+
2737
3030
  function forwardDebugInfo(request, id, debugInfo) {
2738
3031
  for (var i = 0; i < debugInfo.length; i++) {
2739
3032
  request.pendingChunks++;
@@ -2825,8 +3118,8 @@ function retryTask(request, task) {
2825
3118
  }
2826
3119
 
2827
3120
  function performWork(request) {
2828
- var prevDispatcher = ReactCurrentDispatcher.current;
2829
- ReactCurrentDispatcher.current = HooksDispatcher;
3121
+ var prevDispatcher = ReactSharedInternals.H;
3122
+ ReactSharedInternals.H = HooksDispatcher;
2830
3123
  var prevRequest = currentRequest;
2831
3124
  currentRequest = request;
2832
3125
  prepareToUseHooksForRequest(request);
@@ -2847,7 +3140,7 @@ function performWork(request) {
2847
3140
  logRecoverableError(request, error);
2848
3141
  fatalError(request, error);
2849
3142
  } finally {
2850
- ReactCurrentDispatcher.current = prevDispatcher;
3143
+ ReactSharedInternals.H = prevDispatcher;
2851
3144
  resetHooksForRequest();
2852
3145
  currentRequest = prevRequest;
2853
3146
  }