react-server-dom-webpack 19.0.0-canary-e3ebcd54b-20240405 → 19.0.0-canary-4c12339ce-20240408

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 (37) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +32 -8
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +22 -1
  3. package/cjs/react-server-dom-webpack-client.browser.production.min.js +4 -3
  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 +32 -8
  6. package/cjs/react-server-dom-webpack-client.edge.production.js +22 -1
  7. package/cjs/react-server-dom-webpack-client.edge.production.min.js +3 -3
  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 +32 -8
  10. package/cjs/react-server-dom-webpack-client.node.production.js +22 -1
  11. package/cjs/react-server-dom-webpack-client.node.production.min.js +8 -8
  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 +32 -8
  14. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +22 -1
  15. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +31 -31
  16. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -1
  17. package/cjs/react-server-dom-webpack-server.browser.development.js +278 -21
  18. package/cjs/react-server-dom-webpack-server.browser.production.js +24 -5
  19. package/cjs/react-server-dom-webpack-server.browser.production.min.js +45 -45
  20. package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
  21. package/cjs/react-server-dom-webpack-server.edge.development.js +278 -21
  22. package/cjs/react-server-dom-webpack-server.edge.production.js +24 -5
  23. package/cjs/react-server-dom-webpack-server.edge.production.min.js +45 -45
  24. package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
  25. package/cjs/react-server-dom-webpack-server.node.development.js +278 -21
  26. package/cjs/react-server-dom-webpack-server.node.production.js +24 -5
  27. package/cjs/react-server-dom-webpack-server.node.production.min.js +2 -2
  28. package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -1
  29. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +278 -21
  30. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +24 -5
  31. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +2 -2
  32. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
  33. package/package.json +3 -3
  34. package/umd/react-server-dom-webpack-client.browser.development.js +32 -8
  35. package/umd/react-server-dom-webpack-client.browser.production.min.js +16 -16
  36. package/umd/react-server-dom-webpack-server.browser.development.js +278 -21
  37. package/umd/react-server-dom-webpack-server.browser.production.min.js +45 -45
@@ -458,6 +458,7 @@ var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL
458
458
  var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
459
459
  var previousDispatcher = ReactDOMCurrentDispatcher.current;
460
460
  ReactDOMCurrentDispatcher.current = {
461
+ flushSyncWork: previousDispatcher.flushSyncWork,
461
462
  prefetchDNS: prefetchDNS,
462
463
  preconnect: preconnect,
463
464
  preload: preload,
@@ -925,21 +926,34 @@ function getSuspendedThenable() {
925
926
  var currentRequest$1 = null;
926
927
  var thenableIndexCounter = 0;
927
928
  var thenableState = null;
929
+ var currentComponentDebugInfo = null;
928
930
  function prepareToUseHooksForRequest(request) {
929
931
  currentRequest$1 = request;
930
932
  }
931
933
  function resetHooksForRequest() {
932
934
  currentRequest$1 = null;
933
935
  }
934
- function prepareToUseHooksForComponent(prevThenableState) {
936
+ function prepareToUseHooksForComponent(prevThenableState, componentDebugInfo) {
935
937
  thenableIndexCounter = 0;
936
938
  thenableState = prevThenableState;
939
+
940
+ {
941
+ currentComponentDebugInfo = componentDebugInfo;
942
+ }
937
943
  }
938
944
  function getThenableStateAfterSuspending() {
939
945
  // If you use() to Suspend this should always exist but if you throw a Promise instead,
940
946
  // which is not really supported anymore, it will be empty. We use the empty set as a
941
947
  // marker to know if this was a replay of the same component or first attempt.
942
948
  var state = thenableState || createThenableState();
949
+
950
+ {
951
+ // This is a hack but we stash the debug info here so that we don't need a completely
952
+ // different data structure just for this in DEV. Not too happy about it.
953
+ state._componentDebugInfo = currentComponentDebugInfo;
954
+ currentComponentDebugInfo = null;
955
+ }
956
+
943
957
  thenableState = null;
944
958
  return state;
945
959
  }
@@ -1418,6 +1432,7 @@ var SEEN_BUT_NOT_YET_OUTLINED = -1;
1418
1432
  var NEVER_OUTLINED = -2;
1419
1433
  var ReactCurrentCache = ReactSharedServerInternals.ReactCurrentCache;
1420
1434
  var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
1435
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
1421
1436
 
1422
1437
  function defaultErrorHandler(error) {
1423
1438
  console['error'](error); // Don't transform to our wrapper
@@ -1638,33 +1653,56 @@ function createLazyWrapperAroundWakeable(wakeable) {
1638
1653
  return lazyType;
1639
1654
  }
1640
1655
 
1641
- function renderFunctionComponent(request, task, key, Component, props) {
1656
+ function renderFunctionComponent(request, task, key, Component, props, owner) {
1642
1657
  // Reset the task's thenable state before continuing, so that if a later
1643
1658
  // component suspends we can reuse the same task object. If the same
1644
1659
  // component suspends again, the thenable state will be restored.
1645
1660
  var prevThenableState = task.thenableState;
1646
1661
  task.thenableState = null;
1662
+ var componentDebugInfo = null;
1647
1663
 
1648
1664
  {
1649
1665
  if (debugID === null) {
1650
1666
  // We don't have a chunk to assign debug info. We need to outline this
1651
1667
  // component to assign it an ID.
1652
1668
  return outlineTask(request, task);
1653
- } else if (prevThenableState !== null) ; else {
1669
+ } else if (prevThenableState !== null) {
1670
+ // This is a replay and we've already emitted the debug info of this component
1671
+ // in the first pass. We skip emitting a duplicate line.
1672
+ // As a hack we stashed the previous component debug info on this object in DEV.
1673
+ componentDebugInfo = prevThenableState._componentDebugInfo;
1674
+ } else {
1654
1675
  // This is a new component in the same task so we can emit more debug info.
1655
1676
  var componentName = Component.displayName || Component.name || '';
1656
1677
  request.pendingChunks++;
1657
- emitDebugChunk(request, debugID, {
1678
+ var componentDebugID = debugID;
1679
+ componentDebugInfo = {
1658
1680
  name: componentName,
1659
- env: request.environmentName
1660
- });
1681
+ env: request.environmentName,
1682
+ owner: owner
1683
+ }; // We outline this model eagerly so that we can refer to by reference as an owner.
1684
+ // If we had a smarter way to dedupe we might not have to do this if there ends up
1685
+ // being no references to this as an owner.
1686
+
1687
+ outlineModel(request, componentDebugInfo);
1688
+ emitDebugChunk(request, componentDebugID, componentDebugInfo);
1661
1689
  }
1662
1690
  }
1663
1691
 
1664
- prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
1692
+ prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); // The secondArg is always undefined in Server Components since refs error early.
1665
1693
 
1666
1694
  var secondArg = undefined;
1667
- var result = Component(props, secondArg);
1695
+ var result;
1696
+
1697
+ {
1698
+ ReactCurrentOwner.current = componentDebugInfo;
1699
+
1700
+ try {
1701
+ result = Component(props, secondArg);
1702
+ } finally {
1703
+ ReactCurrentOwner.current = null;
1704
+ }
1705
+ }
1668
1706
 
1669
1707
  if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1670
1708
  // When the return value is in children position we can resolve it immediately,
@@ -1755,7 +1793,8 @@ function renderFragment(request, task, children) {
1755
1793
  return children;
1756
1794
  }
1757
1795
 
1758
- function renderClientElement(task, type, key, props) {
1796
+ function renderClientElement(task, type, key, props, owner) // DEV-only
1797
+ {
1759
1798
  // the keys of any Server Components which are not serialized.
1760
1799
 
1761
1800
 
@@ -1767,7 +1806,7 @@ function renderClientElement(task, type, key, props) {
1767
1806
  key = keyPath + ',' + key;
1768
1807
  }
1769
1808
 
1770
- var element = [REACT_ELEMENT_TYPE, type, key, props];
1809
+ var element = [REACT_ELEMENT_TYPE, type, key, props, owner] ;
1771
1810
 
1772
1811
  if (task.implicitSlot && key !== null) {
1773
1812
  // The root Server Component had no key so it was in an implicit slot.
@@ -1805,7 +1844,8 @@ function outlineTask(request, task) {
1805
1844
  return serializeLazyID(newTask.id);
1806
1845
  }
1807
1846
 
1808
- function renderElement(request, task, type, key, ref, props) {
1847
+ function renderElement(request, task, type, key, ref, props, owner) // DEV only
1848
+ {
1809
1849
  if (ref !== null && ref !== undefined) {
1810
1850
  // When the ref moves to the regular props object this will implicitly
1811
1851
  // throw for functions. We could probably relax it to a DEV warning for other
@@ -1826,14 +1866,14 @@ function renderElement(request, task, type, key, ref, props) {
1826
1866
  if (typeof type === 'function') {
1827
1867
  if (isClientReference(type) || isTemporaryReference(type)) {
1828
1868
  // This is a reference to a Client Component.
1829
- return renderClientElement(task, type, key, props);
1869
+ return renderClientElement(task, type, key, props, owner);
1830
1870
  } // This is a Server Component.
1831
1871
 
1832
1872
 
1833
- return renderFunctionComponent(request, task, key, type, props);
1873
+ return renderFunctionComponent(request, task, key, type, props, owner);
1834
1874
  } else if (typeof type === 'string') {
1835
1875
  // This is a host element. E.g. HTML.
1836
- return renderClientElement(task, type, key, props);
1876
+ return renderClientElement(task, type, key, props, owner);
1837
1877
  } else if (typeof type === 'symbol') {
1838
1878
  if (type === REACT_FRAGMENT_TYPE && key === null) {
1839
1879
  // For key-less fragments, we add a small optimization to avoid serializing
@@ -1851,11 +1891,11 @@ function renderElement(request, task, type, key, ref, props) {
1851
1891
  // Any built-in works as long as its props are serializable.
1852
1892
 
1853
1893
 
1854
- return renderClientElement(task, type, key, props);
1894
+ return renderClientElement(task, type, key, props, owner);
1855
1895
  } else if (type != null && typeof type === 'object') {
1856
1896
  if (isClientReference(type)) {
1857
1897
  // This is a reference to a Client Component.
1858
- return renderClientElement(task, type, key, props);
1898
+ return renderClientElement(task, type, key, props, owner);
1859
1899
  }
1860
1900
 
1861
1901
  switch (type.$$typeof) {
@@ -1864,17 +1904,17 @@ function renderElement(request, task, type, key, ref, props) {
1864
1904
  var payload = type._payload;
1865
1905
  var init = type._init;
1866
1906
  var wrappedType = init(payload);
1867
- return renderElement(request, task, wrappedType, key, ref, props);
1907
+ return renderElement(request, task, wrappedType, key, ref, props, owner);
1868
1908
  }
1869
1909
 
1870
1910
  case REACT_FORWARD_REF_TYPE:
1871
1911
  {
1872
- return renderFunctionComponent(request, task, key, type.render, props);
1912
+ return renderFunctionComponent(request, task, key, type.render, props, owner);
1873
1913
  }
1874
1914
 
1875
1915
  case REACT_MEMO_TYPE:
1876
1916
  {
1877
- return renderElement(request, task, type.type, key, ref, props);
1917
+ return renderElement(request, task, type.type, key, ref, props, owner);
1878
1918
  }
1879
1919
  }
1880
1920
  }
@@ -1953,6 +1993,10 @@ function serializeLazyID(id) {
1953
1993
  return '$L' + id.toString(16);
1954
1994
  }
1955
1995
 
1996
+ function serializeInfinitePromise() {
1997
+ return '$@';
1998
+ }
1999
+
1956
2000
  function serializePromiseID(id) {
1957
2001
  return '$@' + id.toString(16);
1958
2002
  }
@@ -2117,6 +2161,12 @@ function serializeMap(request, map) {
2117
2161
  return '$Q' + id.toString(16);
2118
2162
  }
2119
2163
 
2164
+ function serializeFormData(request, formData) {
2165
+ var entries = Array.from(formData.entries());
2166
+ var id = outlineModel(request, entries);
2167
+ return '$K' + id.toString(16);
2168
+ }
2169
+
2120
2170
  function serializeSet(request, set) {
2121
2171
  var entries = Array.from(set);
2122
2172
 
@@ -2293,7 +2343,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2293
2343
 
2294
2344
 
2295
2345
  return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
2296
- element.key, ref, props);
2346
+ element.key, ref, props, element._owner );
2297
2347
  }
2298
2348
 
2299
2349
  case REACT_LAZY_TYPE:
@@ -2391,6 +2441,11 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2391
2441
 
2392
2442
  if (value instanceof Set) {
2393
2443
  return serializeSet(request, value);
2444
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2445
+
2446
+
2447
+ if (typeof FormData === 'function' && value instanceof FormData) {
2448
+ return serializeFormData(request, value);
2394
2449
  }
2395
2450
 
2396
2451
  var iteratorFn = getIteratorFn(value);
@@ -2652,14 +2707,216 @@ function emitModelChunk(request, id, json) {
2652
2707
  }
2653
2708
 
2654
2709
  function emitDebugChunk(request, id, debugInfo) {
2710
+ // use the full serialization that requires a task.
2711
+
2712
+
2713
+ var counter = {
2714
+ objectCount: 0
2715
+ };
2655
2716
 
2717
+ function replacer(parentPropertyName, value) {
2718
+ return renderConsoleValue(request, counter, this, parentPropertyName, value);
2719
+ } // $FlowFixMe[incompatible-type] stringify can return null
2656
2720
 
2657
- var json = stringify(debugInfo);
2721
+
2722
+ var json = stringify(debugInfo, replacer);
2658
2723
  var row = serializeRowHeader('D', id) + json + '\n';
2659
2724
  var processedChunk = stringToChunk(row);
2660
2725
  request.completedRegularChunks.push(processedChunk);
2661
2726
  }
2662
2727
 
2728
+ function serializeEval(source) {
2729
+
2730
+ return '$E' + source;
2731
+ } // This is a forked version of renderModel which should never error, never suspend and is limited
2732
+ // in the depth it can encode.
2733
+
2734
+
2735
+ function renderConsoleValue(request, counter, parent, parentPropertyName, value) {
2736
+ // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
2737
+ // $FlowFixMe[incompatible-use]
2738
+ var originalValue = parent[parentPropertyName];
2739
+
2740
+ if (value === null) {
2741
+ return null;
2742
+ }
2743
+
2744
+ if (typeof value === 'object') {
2745
+ if (isClientReference(value)) {
2746
+ // We actually have this value on the client so we could import it.
2747
+ // This might be confusing though because on the Server it won't actually
2748
+ // be this value, so if you're debugging client references maybe you'd be
2749
+ // better with a place holder.
2750
+ return serializeClientReference(request, parent, parentPropertyName, value);
2751
+ }
2752
+
2753
+ if (counter.objectCount > 20) {
2754
+ // We've reached our max number of objects to serialize across the wire so we serialize this
2755
+ // object but no properties inside of it, as a place holder.
2756
+ return Array.isArray(value) ? [] : {};
2757
+ }
2758
+
2759
+ counter.objectCount++;
2760
+ var writtenObjects = request.writtenObjects;
2761
+ var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
2762
+
2763
+ if (typeof value.then === 'function') {
2764
+ if (existingId !== undefined) {
2765
+ // We've seen this promise before, so we can just refer to the same result.
2766
+ return serializePromiseID(existingId);
2767
+ }
2768
+
2769
+ var thenable = value;
2770
+
2771
+ switch (thenable.status) {
2772
+ case 'fulfilled':
2773
+ {
2774
+ return serializePromiseID(outlineConsoleValue(request, counter, thenable.value));
2775
+ }
2776
+
2777
+ case 'rejected':
2778
+ {
2779
+ var x = thenable.reason;
2780
+ request.pendingChunks++;
2781
+ var errorId = request.nextChunkId++;
2782
+
2783
+ {
2784
+ // We don't log these errors since they didn't actually throw into Flight.
2785
+ var digest = '';
2786
+ emitErrorChunk(request, errorId, digest, x);
2787
+ }
2788
+
2789
+ return serializePromiseID(errorId);
2790
+ }
2791
+ } // If it hasn't already resolved (and been instrumented) we just encode an infinite
2792
+ // promise that will never resolve.
2793
+
2794
+
2795
+ return serializeInfinitePromise();
2796
+ }
2797
+
2798
+ if (existingId !== undefined && existingId >= 0) {
2799
+ // We've already emitted this as a real object, so we can
2800
+ // just refer to that by its existing ID.
2801
+ return serializeByValueID(existingId);
2802
+ }
2803
+
2804
+ if (isArray(value)) {
2805
+ return value;
2806
+ }
2807
+
2808
+ if (value instanceof Map) {
2809
+ return serializeMap(request, value);
2810
+ }
2811
+
2812
+ if (value instanceof Set) {
2813
+ return serializeSet(request, value);
2814
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2815
+
2816
+
2817
+ if (typeof FormData === 'function' && value instanceof FormData) {
2818
+ return serializeFormData(request, value);
2819
+ }
2820
+
2821
+ var iteratorFn = getIteratorFn(value);
2822
+
2823
+ if (iteratorFn) {
2824
+ return Array.from(value);
2825
+ } // $FlowFixMe[incompatible-return]
2826
+
2827
+
2828
+ return value;
2829
+ }
2830
+
2831
+ if (typeof value === 'string') {
2832
+ if (value[value.length - 1] === 'Z') {
2833
+ // Possibly a Date, whose toJSON automatically calls toISOString
2834
+ if (originalValue instanceof Date) {
2835
+ return serializeDateFromDateJSON(value);
2836
+ }
2837
+ }
2838
+
2839
+ if (value.length >= 1024) {
2840
+ // For large strings, we encode them outside the JSON payload so that we
2841
+ // don't have to double encode and double parse the strings. This can also
2842
+ // be more compact in case the string has a lot of escaped characters.
2843
+ return serializeLargeTextString(request, value);
2844
+ }
2845
+
2846
+ return escapeStringValue(value);
2847
+ }
2848
+
2849
+ if (typeof value === 'boolean') {
2850
+ return value;
2851
+ }
2852
+
2853
+ if (typeof value === 'number') {
2854
+ return serializeNumber(value);
2855
+ }
2856
+
2857
+ if (typeof value === 'undefined') {
2858
+ return serializeUndefined();
2859
+ }
2860
+
2861
+ if (typeof value === 'function') {
2862
+ if (isClientReference(value)) {
2863
+ return serializeClientReference(request, parent, parentPropertyName, value);
2864
+ }
2865
+
2866
+ if (isTemporaryReference(value)) {
2867
+ return serializeTemporaryReference(request, value);
2868
+ } // Serialize the body of the function as an eval so it can be printed.
2869
+ // $FlowFixMe[method-unbinding]
2870
+
2871
+
2872
+ return serializeEval('(' + Function.prototype.toString.call(value) + ')');
2873
+ }
2874
+
2875
+ if (typeof value === 'symbol') {
2876
+ var writtenSymbols = request.writtenSymbols;
2877
+
2878
+ var _existingId3 = writtenSymbols.get(value);
2879
+
2880
+ if (_existingId3 !== undefined) {
2881
+ return serializeByValueID(_existingId3);
2882
+ } // $FlowFixMe[incompatible-type] `description` might be undefined
2883
+
2884
+
2885
+ var name = value.description; // We use the Symbol.for version if it's not a global symbol. Close enough.
2886
+
2887
+ request.pendingChunks++;
2888
+ var symbolId = request.nextChunkId++;
2889
+ emitSymbolChunk(request, symbolId, name);
2890
+ return serializeByValueID(symbolId);
2891
+ }
2892
+
2893
+ if (typeof value === 'bigint') {
2894
+ return serializeBigInt(value);
2895
+ }
2896
+
2897
+ return 'unknown type ' + typeof value;
2898
+ }
2899
+
2900
+ function outlineConsoleValue(request, counter, model) {
2901
+
2902
+ function replacer(parentPropertyName, value) {
2903
+ try {
2904
+ return renderConsoleValue(request, counter, this, parentPropertyName, value);
2905
+ } catch (x) {
2906
+ return 'unknown value';
2907
+ }
2908
+ } // $FlowFixMe[incompatible-type] stringify can return null
2909
+
2910
+
2911
+ var json = stringify(model, replacer);
2912
+ request.pendingChunks++;
2913
+ var id = request.nextChunkId++;
2914
+ var row = id.toString(16) + ':' + json + '\n';
2915
+ var processedChunk = stringToChunk(row);
2916
+ request.completedRegularChunks.push(processedChunk);
2917
+ return id;
2918
+ }
2919
+
2663
2920
  function forwardDebugInfo(request, id, debugInfo) {
2664
2921
  for (var i = 0; i < debugInfo.length; i++) {
2665
2922
  request.pendingChunks++;
@@ -410,6 +410,7 @@ const ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WI
410
410
  const ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
411
411
  const previousDispatcher = ReactDOMCurrentDispatcher.current;
412
412
  ReactDOMCurrentDispatcher.current = {
413
+ flushSyncWork: previousDispatcher.flushSyncWork,
413
414
  prefetchDNS,
414
415
  preconnect,
415
416
  preload,
@@ -883,7 +884,7 @@ function prepareToUseHooksForRequest(request) {
883
884
  function resetHooksForRequest() {
884
885
  currentRequest$1 = null;
885
886
  }
886
- function prepareToUseHooksForComponent(prevThenableState) {
887
+ function prepareToUseHooksForComponent(prevThenableState, componentDebugInfo) {
887
888
  thenableIndexCounter = 0;
888
889
  thenableState = prevThenableState;
889
890
  }
@@ -892,6 +893,7 @@ function getThenableStateAfterSuspending() {
892
893
  // which is not really supported anymore, it will be empty. We use the empty set as a
893
894
  // marker to know if this was a replay of the same component or first attempt.
894
895
  const state = thenableState || createThenableState();
896
+
895
897
  thenableState = null;
896
898
  return state;
897
899
  }
@@ -1446,7 +1448,7 @@ function createLazyWrapperAroundWakeable(wakeable) {
1446
1448
  return lazyType;
1447
1449
  }
1448
1450
 
1449
- function renderFunctionComponent(request, task, key, Component, props) {
1451
+ function renderFunctionComponent(request, task, key, Component, props, owner) {
1450
1452
  // Reset the task's thenable state before continuing, so that if a later
1451
1453
  // component suspends we can reuse the same task object. If the same
1452
1454
  // component suspends again, the thenable state will be restored.
@@ -1456,7 +1458,11 @@ function renderFunctionComponent(request, task, key, Component, props) {
1456
1458
  prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
1457
1459
 
1458
1460
  const secondArg = undefined;
1459
- let result = Component(props, secondArg);
1461
+ let result;
1462
+
1463
+ {
1464
+ result = Component(props, secondArg);
1465
+ }
1460
1466
 
1461
1467
  if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1462
1468
  // When the return value is in children position we can resolve it immediately,
@@ -1530,7 +1536,8 @@ function renderFragment(request, task, children) {
1530
1536
  return children;
1531
1537
  }
1532
1538
 
1533
- function renderClientElement(task, type, key, props) {
1539
+ function renderClientElement(task, type, key, props, owner) // DEV-only
1540
+ {
1534
1541
  // the keys of any Server Components which are not serialized.
1535
1542
 
1536
1543
 
@@ -1563,7 +1570,8 @@ function renderClientElement(task, type, key, props) {
1563
1570
 
1564
1571
  let debugID = null;
1565
1572
 
1566
- function renderElement(request, task, type, key, ref, props) {
1573
+ function renderElement(request, task, type, key, ref, props, owner) // DEV only
1574
+ {
1567
1575
  if (ref !== null && ref !== undefined) {
1568
1576
  // When the ref moves to the regular props object this will implicitly
1569
1577
  // throw for functions. We could probably relax it to a DEV warning for other
@@ -1844,6 +1852,12 @@ function serializeMap(request, map) {
1844
1852
  return '$Q' + id.toString(16);
1845
1853
  }
1846
1854
 
1855
+ function serializeFormData(request, formData) {
1856
+ const entries = Array.from(formData.entries());
1857
+ const id = outlineModel(request, entries);
1858
+ return '$K' + id.toString(16);
1859
+ }
1860
+
1847
1861
  function serializeSet(request, set) {
1848
1862
  const entries = Array.from(set);
1849
1863
 
@@ -2080,6 +2094,11 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2080
2094
 
2081
2095
  if (value instanceof Set) {
2082
2096
  return serializeSet(request, value);
2097
+ } // TODO: FormData is not available in old Node. Remove the typeof later.
2098
+
2099
+
2100
+ if (typeof FormData === 'function' && value instanceof FormData) {
2101
+ return serializeFormData(request, value);
2083
2102
  }
2084
2103
 
2085
2104
  const iteratorFn = getIteratorFn(value);