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
@@ -14,7 +14,12 @@
14
14
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactServerDOMServer = {}, global.React, global.ReactDOM));
15
15
  })(this, (function (exports, React, ReactDOM) { 'use strict';
16
16
 
17
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
17
+ var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
18
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
19
+
20
+ if (!ReactSharedInternalsServer) {
21
+ 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.');
22
+ }
18
23
 
19
24
  function error(format) {
20
25
  {
@@ -32,8 +37,7 @@
32
37
  // When changing this logic, you might want to also
33
38
  // update consoleWithStackDev.www.js as well.
34
39
  {
35
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
36
- var stack = ReactDebugCurrentFrame.getStackAddendum();
40
+ var stack = ReactSharedInternalsServer.getStackAddendum();
37
41
 
38
42
  if (stack !== '') {
39
43
  format += '%s';
@@ -450,18 +454,45 @@
450
454
  return serverReference.$$bound;
451
455
  }
452
456
 
453
- var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
454
-
455
- var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
456
- var previousDispatcher = ReactDOMCurrentDispatcher.current;
457
- ReactDOMCurrentDispatcher.current = {
458
- prefetchDNS: prefetchDNS,
459
- preconnect: preconnect,
460
- preload: preload,
461
- preloadModule: preloadModule$1,
462
- preinitStyle: preinitStyle,
463
- preinitScript: preinitScript,
464
- preinitModuleScript: preinitModuleScript
457
+ var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
458
+
459
+ var previousDispatcher = ReactDOMSharedInternals.d;
460
+ /* ReactDOMCurrentDispatcher */
461
+
462
+ ReactDOMSharedInternals.d
463
+ /* ReactDOMCurrentDispatcher */
464
+ = {
465
+ f
466
+ /* flushSyncWork */
467
+ : previousDispatcher.f
468
+ /* flushSyncWork */
469
+ ,
470
+ r
471
+ /* requestFormReset */
472
+ : previousDispatcher.r
473
+ /* requestFormReset */
474
+ ,
475
+ D
476
+ /* prefetchDNS */
477
+ : prefetchDNS,
478
+ C
479
+ /* preconnect */
480
+ : preconnect,
481
+ L
482
+ /* preload */
483
+ : preload,
484
+ m
485
+ /* preloadModule */
486
+ : preloadModule$1,
487
+ X
488
+ /* preinitScript */
489
+ : preinitScript,
490
+ S
491
+ /* preinitStyle */
492
+ : preinitStyle,
493
+ M
494
+ /* preinitModuleScript */
495
+ : preinitModuleScript
465
496
  };
466
497
 
467
498
  function prefetchDNS(href) {
@@ -480,7 +511,9 @@
480
511
  hints.add(key);
481
512
  emitHint(request, 'D', href);
482
513
  } else {
483
- previousDispatcher.prefetchDNS(href);
514
+ previousDispatcher.D(
515
+ /* prefetchDNS */
516
+ href);
484
517
  }
485
518
  }
486
519
  }
@@ -506,7 +539,9 @@
506
539
  emitHint(request, 'C', href);
507
540
  }
508
541
  } else {
509
- previousDispatcher.preconnect(href, crossOrigin);
542
+ previousDispatcher.C(
543
+ /* preconnect */
544
+ href, crossOrigin);
510
545
  }
511
546
  }
512
547
  }
@@ -539,7 +574,9 @@
539
574
  emitHint(request, 'L', [href, as]);
540
575
  }
541
576
  } else {
542
- previousDispatcher.preload(href, as, options);
577
+ previousDispatcher.L(
578
+ /* preload */
579
+ href, as, options);
543
580
  }
544
581
  }
545
582
  }
@@ -566,7 +603,9 @@
566
603
  return emitHint(request, 'm', href);
567
604
  }
568
605
  } else {
569
- previousDispatcher.preloadModule(href, options);
606
+ previousDispatcher.m(
607
+ /* preloadModule */
608
+ href, options);
570
609
  }
571
610
  }
572
611
  }
@@ -595,7 +634,9 @@
595
634
  return emitHint(request, 'S', href);
596
635
  }
597
636
  } else {
598
- previousDispatcher.preinitStyle(href, precedence, options);
637
+ previousDispatcher.S(
638
+ /* preinitStyle */
639
+ href, precedence, options);
599
640
  }
600
641
  }
601
642
  }
@@ -622,7 +663,9 @@
622
663
  return emitHint(request, 'X', src);
623
664
  }
624
665
  } else {
625
- previousDispatcher.preinitScript(src, options);
666
+ previousDispatcher.X(
667
+ /* preinitScript */
668
+ src, options);
626
669
  }
627
670
  }
628
671
  }
@@ -649,7 +692,9 @@
649
692
  return emitHint(request, 'M', src);
650
693
  }
651
694
  } else {
652
- previousDispatcher.preinitModuleScript(src, options);
695
+ previousDispatcher.M(
696
+ /* preinitModuleScript */
697
+ src, options);
653
698
  }
654
699
  }
655
700
  } // Flight normally encodes undefined as a special character however for directive option
@@ -922,21 +967,34 @@
922
967
  var currentRequest$1 = null;
923
968
  var thenableIndexCounter = 0;
924
969
  var thenableState = null;
970
+ var currentComponentDebugInfo = null;
925
971
  function prepareToUseHooksForRequest(request) {
926
972
  currentRequest$1 = request;
927
973
  }
928
974
  function resetHooksForRequest() {
929
975
  currentRequest$1 = null;
930
976
  }
931
- function prepareToUseHooksForComponent(prevThenableState) {
977
+ function prepareToUseHooksForComponent(prevThenableState, componentDebugInfo) {
932
978
  thenableIndexCounter = 0;
933
979
  thenableState = prevThenableState;
980
+
981
+ {
982
+ currentComponentDebugInfo = componentDebugInfo;
983
+ }
934
984
  }
935
985
  function getThenableStateAfterSuspending() {
936
986
  // If you use() to Suspend this should always exist but if you throw a Promise instead,
937
987
  // which is not really supported anymore, it will be empty. We use the empty set as a
938
988
  // marker to know if this was a replay of the same component or first attempt.
939
989
  var state = thenableState || createThenableState();
990
+
991
+ {
992
+ // This is a hack but we stash the debug info here so that we don't need a completely
993
+ // different data structure just for this in DEV. Not too happy about it.
994
+ state._componentDebugInfo = currentComponentDebugInfo;
995
+ currentComponentDebugInfo = null;
996
+ }
997
+
940
998
  thenableState = null;
941
999
  return state;
942
1000
  }
@@ -1394,12 +1452,7 @@
1394
1452
  return '\n ' + str;
1395
1453
  }
1396
1454
 
1397
- var ReactSharedServerInternals = // $FlowFixMe: It's defined in the one we resolve to.
1398
- React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1399
-
1400
- if (!ReactSharedServerInternals) {
1401
- 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.');
1402
- }
1455
+ var ReactSharedInternals = ReactSharedInternalsServer;
1403
1456
 
1404
1457
  var ObjectPrototype = Object.prototype;
1405
1458
  var stringify = JSON.stringify; // Serializable values
@@ -1413,8 +1466,6 @@
1413
1466
 
1414
1467
  var SEEN_BUT_NOT_YET_OUTLINED = -1;
1415
1468
  var NEVER_OUTLINED = -2;
1416
- var ReactCurrentCache = ReactSharedServerInternals.ReactCurrentCache;
1417
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
1418
1469
 
1419
1470
  function defaultErrorHandler(error) {
1420
1471
  console['error'](error); // Don't transform to our wrapper
@@ -1427,11 +1478,11 @@
1427
1478
  var CLOSING = 1;
1428
1479
  var CLOSED = 2;
1429
1480
  function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
1430
- if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
1481
+ if (ReactSharedInternals.C !== null && ReactSharedInternals.C !== DefaultCacheDispatcher) {
1431
1482
  throw new Error('Currently React only supports one RSC renderer at a time.');
1432
1483
  }
1433
1484
 
1434
- ReactCurrentCache.current = DefaultCacheDispatcher;
1485
+ ReactSharedInternals.C = DefaultCacheDispatcher;
1435
1486
  var abortSet = new Set();
1436
1487
  var pingedTasks = [];
1437
1488
  var cleanupQueue = [];
@@ -1635,33 +1686,56 @@
1635
1686
  return lazyType;
1636
1687
  }
1637
1688
 
1638
- function renderFunctionComponent(request, task, key, Component, props) {
1689
+ function renderFunctionComponent(request, task, key, Component, props, owner) {
1639
1690
  // Reset the task's thenable state before continuing, so that if a later
1640
1691
  // component suspends we can reuse the same task object. If the same
1641
1692
  // component suspends again, the thenable state will be restored.
1642
1693
  var prevThenableState = task.thenableState;
1643
1694
  task.thenableState = null;
1695
+ var componentDebugInfo = null;
1644
1696
 
1645
1697
  {
1646
1698
  if (debugID === null) {
1647
1699
  // We don't have a chunk to assign debug info. We need to outline this
1648
1700
  // component to assign it an ID.
1649
1701
  return outlineTask(request, task);
1650
- } else if (prevThenableState !== null) ; else {
1702
+ } else if (prevThenableState !== null) {
1703
+ // This is a replay and we've already emitted the debug info of this component
1704
+ // in the first pass. We skip emitting a duplicate line.
1705
+ // As a hack we stashed the previous component debug info on this object in DEV.
1706
+ componentDebugInfo = prevThenableState._componentDebugInfo;
1707
+ } else {
1651
1708
  // This is a new component in the same task so we can emit more debug info.
1652
1709
  var componentName = Component.displayName || Component.name || '';
1653
1710
  request.pendingChunks++;
1654
- emitDebugChunk(request, debugID, {
1711
+ var componentDebugID = debugID;
1712
+ componentDebugInfo = {
1655
1713
  name: componentName,
1656
- env: request.environmentName
1657
- });
1714
+ env: request.environmentName,
1715
+ owner: owner
1716
+ }; // We outline this model eagerly so that we can refer to by reference as an owner.
1717
+ // If we had a smarter way to dedupe we might not have to do this if there ends up
1718
+ // being no references to this as an owner.
1719
+
1720
+ outlineModel(request, componentDebugInfo);
1721
+ emitDebugChunk(request, componentDebugID, componentDebugInfo);
1658
1722
  }
1659
1723
  }
1660
1724
 
1661
- prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
1725
+ prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); // The secondArg is always undefined in Server Components since refs error early.
1662
1726
 
1663
1727
  var secondArg = undefined;
1664
- var result = Component(props, secondArg);
1728
+ var result;
1729
+
1730
+ {
1731
+ ReactSharedInternals.owner = componentDebugInfo;
1732
+
1733
+ try {
1734
+ result = Component(props, secondArg);
1735
+ } finally {
1736
+ ReactSharedInternals.owner = null;
1737
+ }
1738
+ }
1665
1739
 
1666
1740
  if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1667
1741
  // When the return value is in children position we can resolve it immediately,
@@ -1752,7 +1826,8 @@
1752
1826
  return children;
1753
1827
  }
1754
1828
 
1755
- function renderClientElement(task, type, key, props) {
1829
+ function renderClientElement(task, type, key, props, owner) // DEV-only
1830
+ {
1756
1831
  // the keys of any Server Components which are not serialized.
1757
1832
 
1758
1833
 
@@ -1764,7 +1839,7 @@
1764
1839
  key = keyPath + ',' + key;
1765
1840
  }
1766
1841
 
1767
- var element = [REACT_ELEMENT_TYPE, type, key, props];
1842
+ var element = [REACT_ELEMENT_TYPE, type, key, props, owner] ;
1768
1843
 
1769
1844
  if (task.implicitSlot && key !== null) {
1770
1845
  // The root Server Component had no key so it was in an implicit slot.
@@ -1802,7 +1877,8 @@
1802
1877
  return serializeLazyID(newTask.id);
1803
1878
  }
1804
1879
 
1805
- function renderElement(request, task, type, key, ref, props) {
1880
+ function renderElement(request, task, type, key, ref, props, owner) // DEV only
1881
+ {
1806
1882
  if (ref !== null && ref !== undefined) {
1807
1883
  // When the ref moves to the regular props object this will implicitly
1808
1884
  // throw for functions. We could probably relax it to a DEV warning for other
@@ -1823,14 +1899,14 @@
1823
1899
  if (typeof type === 'function') {
1824
1900
  if (isClientReference(type) || isTemporaryReference(type)) {
1825
1901
  // This is a reference to a Client Component.
1826
- return renderClientElement(task, type, key, props);
1902
+ return renderClientElement(task, type, key, props, owner);
1827
1903
  } // This is a Server Component.
1828
1904
 
1829
1905
 
1830
- return renderFunctionComponent(request, task, key, type, props);
1906
+ return renderFunctionComponent(request, task, key, type, props, owner);
1831
1907
  } else if (typeof type === 'string') {
1832
1908
  // This is a host element. E.g. HTML.
1833
- return renderClientElement(task, type, key, props);
1909
+ return renderClientElement(task, type, key, props, owner);
1834
1910
  } else if (typeof type === 'symbol') {
1835
1911
  if (type === REACT_FRAGMENT_TYPE && key === null) {
1836
1912
  // For key-less fragments, we add a small optimization to avoid serializing
@@ -1848,11 +1924,11 @@
1848
1924
  // Any built-in works as long as its props are serializable.
1849
1925
 
1850
1926
 
1851
- return renderClientElement(task, type, key, props);
1927
+ return renderClientElement(task, type, key, props, owner);
1852
1928
  } else if (type != null && typeof type === 'object') {
1853
1929
  if (isClientReference(type)) {
1854
1930
  // This is a reference to a Client Component.
1855
- return renderClientElement(task, type, key, props);
1931
+ return renderClientElement(task, type, key, props, owner);
1856
1932
  }
1857
1933
 
1858
1934
  switch (type.$$typeof) {
@@ -1861,17 +1937,17 @@
1861
1937
  var payload = type._payload;
1862
1938
  var init = type._init;
1863
1939
  var wrappedType = init(payload);
1864
- return renderElement(request, task, wrappedType, key, ref, props);
1940
+ return renderElement(request, task, wrappedType, key, ref, props, owner);
1865
1941
  }
1866
1942
 
1867
1943
  case REACT_FORWARD_REF_TYPE:
1868
1944
  {
1869
- return renderFunctionComponent(request, task, key, type.render, props);
1945
+ return renderFunctionComponent(request, task, key, type.render, props, owner);
1870
1946
  }
1871
1947
 
1872
1948
  case REACT_MEMO_TYPE:
1873
1949
  {
1874
- return renderElement(request, task, type.type, key, ref, props);
1950
+ return renderElement(request, task, type.type, key, ref, props, owner);
1875
1951
  }
1876
1952
  }
1877
1953
  }
@@ -1950,6 +2026,10 @@
1950
2026
  return '$L' + id.toString(16);
1951
2027
  }
1952
2028
 
2029
+ function serializeInfinitePromise() {
2030
+ return '$@';
2031
+ }
2032
+
1953
2033
  function serializePromiseID(id) {
1954
2034
  return '$@' + id.toString(16);
1955
2035
  }
@@ -2114,6 +2194,12 @@
2114
2194
  return '$Q' + id.toString(16);
2115
2195
  }
2116
2196
 
2197
+ function serializeFormData(request, formData) {
2198
+ var entries = Array.from(formData.entries());
2199
+ var id = outlineModel(request, entries);
2200
+ return '$K' + id.toString(16);
2201
+ }
2202
+
2117
2203
  function serializeSet(request, set) {
2118
2204
  var entries = Array.from(set);
2119
2205
 
@@ -2290,7 +2376,7 @@
2290
2376
 
2291
2377
 
2292
2378
  return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
2293
- element.key, ref, props);
2379
+ element.key, ref, props, element._owner );
2294
2380
  }
2295
2381
 
2296
2382
  case REACT_LAZY_TYPE:
@@ -2388,6 +2474,11 @@
2388
2474
 
2389
2475
  if (value instanceof Set) {
2390
2476
  return serializeSet(request, value);
2477
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2478
+
2479
+
2480
+ if (typeof FormData === 'function' && value instanceof FormData) {
2481
+ return serializeFormData(request, value);
2391
2482
  }
2392
2483
 
2393
2484
  var iteratorFn = getIteratorFn(value);
@@ -2649,14 +2740,216 @@
2649
2740
  }
2650
2741
 
2651
2742
  function emitDebugChunk(request, id, debugInfo) {
2743
+ // use the full serialization that requires a task.
2652
2744
 
2653
2745
 
2654
- var json = stringify(debugInfo);
2746
+ var counter = {
2747
+ objectCount: 0
2748
+ };
2749
+
2750
+ function replacer(parentPropertyName, value) {
2751
+ return renderConsoleValue(request, counter, this, parentPropertyName, value);
2752
+ } // $FlowFixMe[incompatible-type] stringify can return null
2753
+
2754
+
2755
+ var json = stringify(debugInfo, replacer);
2655
2756
  var row = serializeRowHeader('D', id) + json + '\n';
2656
2757
  var processedChunk = stringToChunk(row);
2657
2758
  request.completedRegularChunks.push(processedChunk);
2658
2759
  }
2659
2760
 
2761
+ function serializeEval(source) {
2762
+
2763
+ return '$E' + source;
2764
+ } // This is a forked version of renderModel which should never error, never suspend and is limited
2765
+ // in the depth it can encode.
2766
+
2767
+
2768
+ function renderConsoleValue(request, counter, parent, parentPropertyName, value) {
2769
+ // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
2770
+ // $FlowFixMe[incompatible-use]
2771
+ var originalValue = parent[parentPropertyName];
2772
+
2773
+ if (value === null) {
2774
+ return null;
2775
+ }
2776
+
2777
+ if (typeof value === 'object') {
2778
+ if (isClientReference(value)) {
2779
+ // We actually have this value on the client so we could import it.
2780
+ // This might be confusing though because on the Server it won't actually
2781
+ // be this value, so if you're debugging client references maybe you'd be
2782
+ // better with a place holder.
2783
+ return serializeClientReference(request, parent, parentPropertyName, value);
2784
+ }
2785
+
2786
+ if (counter.objectCount > 20) {
2787
+ // We've reached our max number of objects to serialize across the wire so we serialize this
2788
+ // object but no properties inside of it, as a place holder.
2789
+ return Array.isArray(value) ? [] : {};
2790
+ }
2791
+
2792
+ counter.objectCount++;
2793
+ var writtenObjects = request.writtenObjects;
2794
+ var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
2795
+
2796
+ if (typeof value.then === 'function') {
2797
+ if (existingId !== undefined) {
2798
+ // We've seen this promise before, so we can just refer to the same result.
2799
+ return serializePromiseID(existingId);
2800
+ }
2801
+
2802
+ var thenable = value;
2803
+
2804
+ switch (thenable.status) {
2805
+ case 'fulfilled':
2806
+ {
2807
+ return serializePromiseID(outlineConsoleValue(request, counter, thenable.value));
2808
+ }
2809
+
2810
+ case 'rejected':
2811
+ {
2812
+ var x = thenable.reason;
2813
+ request.pendingChunks++;
2814
+ var errorId = request.nextChunkId++;
2815
+
2816
+ {
2817
+ // We don't log these errors since they didn't actually throw into Flight.
2818
+ var digest = '';
2819
+ emitErrorChunk(request, errorId, digest, x);
2820
+ }
2821
+
2822
+ return serializePromiseID(errorId);
2823
+ }
2824
+ } // If it hasn't already resolved (and been instrumented) we just encode an infinite
2825
+ // promise that will never resolve.
2826
+
2827
+
2828
+ return serializeInfinitePromise();
2829
+ }
2830
+
2831
+ if (existingId !== undefined && existingId >= 0) {
2832
+ // We've already emitted this as a real object, so we can
2833
+ // just refer to that by its existing ID.
2834
+ return serializeByValueID(existingId);
2835
+ }
2836
+
2837
+ if (isArray(value)) {
2838
+ return value;
2839
+ }
2840
+
2841
+ if (value instanceof Map) {
2842
+ return serializeMap(request, value);
2843
+ }
2844
+
2845
+ if (value instanceof Set) {
2846
+ return serializeSet(request, value);
2847
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2848
+
2849
+
2850
+ if (typeof FormData === 'function' && value instanceof FormData) {
2851
+ return serializeFormData(request, value);
2852
+ }
2853
+
2854
+ var iteratorFn = getIteratorFn(value);
2855
+
2856
+ if (iteratorFn) {
2857
+ return Array.from(value);
2858
+ } // $FlowFixMe[incompatible-return]
2859
+
2860
+
2861
+ return value;
2862
+ }
2863
+
2864
+ if (typeof value === 'string') {
2865
+ if (value[value.length - 1] === 'Z') {
2866
+ // Possibly a Date, whose toJSON automatically calls toISOString
2867
+ if (originalValue instanceof Date) {
2868
+ return serializeDateFromDateJSON(value);
2869
+ }
2870
+ }
2871
+
2872
+ if (value.length >= 1024) {
2873
+ // For large strings, we encode them outside the JSON payload so that we
2874
+ // don't have to double encode and double parse the strings. This can also
2875
+ // be more compact in case the string has a lot of escaped characters.
2876
+ return serializeLargeTextString(request, value);
2877
+ }
2878
+
2879
+ return escapeStringValue(value);
2880
+ }
2881
+
2882
+ if (typeof value === 'boolean') {
2883
+ return value;
2884
+ }
2885
+
2886
+ if (typeof value === 'number') {
2887
+ return serializeNumber(value);
2888
+ }
2889
+
2890
+ if (typeof value === 'undefined') {
2891
+ return serializeUndefined();
2892
+ }
2893
+
2894
+ if (typeof value === 'function') {
2895
+ if (isClientReference(value)) {
2896
+ return serializeClientReference(request, parent, parentPropertyName, value);
2897
+ }
2898
+
2899
+ if (isTemporaryReference(value)) {
2900
+ return serializeTemporaryReference(request, value);
2901
+ } // Serialize the body of the function as an eval so it can be printed.
2902
+ // $FlowFixMe[method-unbinding]
2903
+
2904
+
2905
+ return serializeEval('(' + Function.prototype.toString.call(value) + ')');
2906
+ }
2907
+
2908
+ if (typeof value === 'symbol') {
2909
+ var writtenSymbols = request.writtenSymbols;
2910
+
2911
+ var _existingId3 = writtenSymbols.get(value);
2912
+
2913
+ if (_existingId3 !== undefined) {
2914
+ return serializeByValueID(_existingId3);
2915
+ } // $FlowFixMe[incompatible-type] `description` might be undefined
2916
+
2917
+
2918
+ var name = value.description; // We use the Symbol.for version if it's not a global symbol. Close enough.
2919
+
2920
+ request.pendingChunks++;
2921
+ var symbolId = request.nextChunkId++;
2922
+ emitSymbolChunk(request, symbolId, name);
2923
+ return serializeByValueID(symbolId);
2924
+ }
2925
+
2926
+ if (typeof value === 'bigint') {
2927
+ return serializeBigInt(value);
2928
+ }
2929
+
2930
+ return 'unknown type ' + typeof value;
2931
+ }
2932
+
2933
+ function outlineConsoleValue(request, counter, model) {
2934
+
2935
+ function replacer(parentPropertyName, value) {
2936
+ try {
2937
+ return renderConsoleValue(request, counter, this, parentPropertyName, value);
2938
+ } catch (x) {
2939
+ return 'unknown value';
2940
+ }
2941
+ } // $FlowFixMe[incompatible-type] stringify can return null
2942
+
2943
+
2944
+ var json = stringify(model, replacer);
2945
+ request.pendingChunks++;
2946
+ var id = request.nextChunkId++;
2947
+ var row = id.toString(16) + ':' + json + '\n';
2948
+ var processedChunk = stringToChunk(row);
2949
+ request.completedRegularChunks.push(processedChunk);
2950
+ return id;
2951
+ }
2952
+
2660
2953
  function forwardDebugInfo(request, id, debugInfo) {
2661
2954
  for (var i = 0; i < debugInfo.length; i++) {
2662
2955
  request.pendingChunks++;
@@ -2748,8 +3041,8 @@
2748
3041
  }
2749
3042
 
2750
3043
  function performWork(request) {
2751
- var prevDispatcher = ReactCurrentDispatcher.current;
2752
- ReactCurrentDispatcher.current = HooksDispatcher;
3044
+ var prevDispatcher = ReactSharedInternals.H;
3045
+ ReactSharedInternals.H = HooksDispatcher;
2753
3046
  var prevRequest = currentRequest;
2754
3047
  currentRequest = request;
2755
3048
  prepareToUseHooksForRequest(request);
@@ -2770,7 +3063,7 @@
2770
3063
  logRecoverableError(request, error);
2771
3064
  fatalError(request, error);
2772
3065
  } finally {
2773
- ReactCurrentDispatcher.current = prevDispatcher;
3066
+ ReactSharedInternals.H = prevDispatcher;
2774
3067
  resetHooksForRequest();
2775
3068
  currentRequest = prevRequest;
2776
3069
  }