react-server-dom-webpack 18.3.0-canary-14898b6a9-20240318 → 18.3.0-canary-4b84f1161-20240318

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 (39) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +91 -189
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +60 -43
  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 +96 -241
  6. package/cjs/react-server-dom-webpack-client.edge.production.js +65 -84
  7. package/cjs/react-server-dom-webpack-client.edge.production.min.js +29 -29
  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 +96 -241
  10. package/cjs/react-server-dom-webpack-client.node.production.js +65 -84
  11. package/cjs/react-server-dom-webpack-client.node.production.min.js +29 -28
  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 +96 -241
  14. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +65 -84
  15. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +30 -30
  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-plugin.js.map +1 -1
  19. package/cjs/react-server-dom-webpack-server.browser.development.js +406 -550
  20. package/cjs/react-server-dom-webpack-server.browser.production.js +351 -373
  21. package/cjs/react-server-dom-webpack-server.browser.production.min.js +68 -65
  22. package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
  23. package/cjs/react-server-dom-webpack-server.edge.development.js +406 -553
  24. package/cjs/react-server-dom-webpack-server.edge.production.js +350 -375
  25. package/cjs/react-server-dom-webpack-server.edge.production.min.js +69 -66
  26. package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
  27. package/cjs/react-server-dom-webpack-server.node.development.js +406 -550
  28. package/cjs/react-server-dom-webpack-server.node.production.js +350 -372
  29. package/cjs/react-server-dom-webpack-server.node.production.min.js +72 -70
  30. package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -1
  31. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +406 -550
  32. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +350 -372
  33. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +69 -67
  34. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
  35. package/package.json +3 -3
  36. package/umd/react-server-dom-webpack-client.browser.development.js +91 -189
  37. package/umd/react-server-dom-webpack-client.browser.production.min.js +23 -22
  38. package/umd/react-server-dom-webpack-server.browser.development.js +406 -550
  39. package/umd/react-server-dom-webpack-server.browser.production.min.js +52 -52
@@ -33,48 +33,6 @@ function readFinalStringChunk(decoder, buffer) {
33
33
  return decoder.decode(buffer);
34
34
  }
35
35
 
36
- var badgeFormat = '%c%s%c '; // Same badge styling as DevTools.
37
-
38
- var badgeStyle = // We use a fixed background if light-dark is not supported, otherwise
39
- // we use a transparent background.
40
- 'background: #e6e6e6;' + 'background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));' + 'color: #000000;' + 'color: light-dark(#000000, #ffffff);' + 'border-radius: 2px';
41
- var resetStyle = '';
42
- var pad = ' ';
43
- function printToConsole(methodName, args, badgeName) {
44
- var offset = 0;
45
-
46
- switch (methodName) {
47
- case 'dir':
48
- case 'dirxml':
49
- case 'groupEnd':
50
- case 'table':
51
- {
52
- // These methods cannot be colorized because they don't take a formatting string.
53
- // eslint-disable-next-line react-internal/no-production-logging
54
- console[methodName].apply(console, args);
55
- return;
56
- }
57
-
58
- case 'assert':
59
- {
60
- // assert takes formatting options as the second argument.
61
- offset = 1;
62
- }
63
- }
64
-
65
- var newArgs = args.slice(0);
66
-
67
- if (typeof newArgs[offset] === 'string') {
68
- newArgs.splice(offset, 1, badgeFormat + newArgs[offset], badgeStyle, pad + badgeName + pad, resetStyle);
69
- } else {
70
- newArgs.splice(offset, 0, badgeFormat, badgeStyle, pad + badgeName + pad, resetStyle);
71
- } // eslint-disable-next-line react-internal/no-production-logging
72
-
73
-
74
- console[methodName].apply(console, newArgs);
75
- return;
76
- }
77
-
78
36
  // This is the parsed shape of the wire format which is why it is
79
37
  // condensed to only the essentialy information
80
38
  var ID = 0;
@@ -413,12 +371,14 @@ function printWarning(level, format, args) {
413
371
  // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
414
372
  // The Symbol used to tag the ReactElement-like types.
415
373
  var REACT_ELEMENT_TYPE = Symbol.for('react.element');
416
- var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); // TODO: Delete with enableRenderableContext
374
+ var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
375
+ var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
417
376
  var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
418
377
  var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
419
378
  var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
420
379
  var REACT_MEMO_TYPE = Symbol.for('react.memo');
421
380
  var REACT_LAZY_TYPE = Symbol.for('react.lazy');
381
+ var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
422
382
  var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
423
383
  var FAUX_ITERATOR_SYMBOL = '@@iterator';
424
384
  function getIteratorFn(maybeIterable) {
@@ -530,10 +490,6 @@ function describeValueForErrorMessage(value) {
530
490
  return '[...]';
531
491
  }
532
492
 
533
- if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
534
- return describeClientReference();
535
- }
536
-
537
493
  var name = objectName(value);
538
494
 
539
495
  if (name === 'Object') {
@@ -544,15 +500,7 @@ function describeValueForErrorMessage(value) {
544
500
  }
545
501
 
546
502
  case 'function':
547
- {
548
- if (value.$$typeof === CLIENT_REFERENCE_TAG) {
549
- return describeClientReference();
550
- }
551
-
552
- var _name = value.displayName || value.name;
553
-
554
- return _name ? 'function ' + _name : 'function';
555
- }
503
+ return 'function';
556
504
 
557
505
  default:
558
506
  // eslint-disable-next-line react-internal/safe-string-coercion
@@ -598,12 +546,6 @@ function describeElementType(type) {
598
546
  return '';
599
547
  }
600
548
 
601
- var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
602
-
603
- function describeClientReference(ref) {
604
- return 'client';
605
- }
606
-
607
549
  function describeObjectForErrorMessage(objectOrArray, expandedName) {
608
550
  var objKind = objectName(objectOrArray);
609
551
 
@@ -682,8 +624,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
682
624
  } else {
683
625
  if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
684
626
  str = '<' + describeElementType(objectOrArray.type) + '/>';
685
- } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
686
- return describeClientReference();
687
627
  } else if (jsxPropsParents.has(objectOrArray)) {
688
628
  // Print JSX
689
629
  var _type = jsxPropsParents.get(objectOrArray);
@@ -734,9 +674,9 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
734
674
  str += ', ';
735
675
  }
736
676
 
737
- var _name2 = _names[_i3];
738
- str += describeKeyForErrorMessage(_name2) + ': ';
739
- var _value3 = _object[_name2];
677
+ var _name = _names[_i3];
678
+ str += describeKeyForErrorMessage(_name) + ': ';
679
+ var _value3 = _object[_name];
740
680
 
741
681
  var _substr3 = void 0;
742
682
 
@@ -746,7 +686,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
746
686
  _substr3 = describeValueForErrorMessage(_value3);
747
687
  }
748
688
 
749
- if (_name2 === expandedName) {
689
+ if (_name === expandedName) {
750
690
  start = str.length;
751
691
  length = _substr3.length;
752
692
  str += _substr3;
@@ -971,7 +911,7 @@ function processReply(root, formFieldPrefix, resolve, reject) {
971
911
  error('React Element cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
972
912
  } else if (value.$$typeof === REACT_LAZY_TYPE) {
973
913
  error('React Lazy cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
974
- } else if (value.$$typeof === (REACT_PROVIDER_TYPE)) {
914
+ } else if (value.$$typeof === REACT_PROVIDER_TYPE) {
975
915
  error('React Context Providers cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
976
916
  } else if (objectName(value) !== 'Object') {
977
917
  error('Only plain objects can be passed to Server Functions from the Client. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
@@ -1075,12 +1015,12 @@ function processReply(root, formFieldPrefix, resolve, reject) {
1075
1015
  }
1076
1016
  }
1077
1017
 
1078
- function registerServerReference(proxy, reference, encodeFormAction) {
1018
+ function registerServerReference(proxy, reference) {
1079
1019
 
1080
1020
  knownServerReferences.set(proxy, reference);
1081
1021
  } // $FlowFixMe[method-unbinding]
1082
1022
 
1083
- function createServerReference(id, callServer, encodeFormAction) {
1023
+ function createServerReference(id, callServer) {
1084
1024
  var proxy = function () {
1085
1025
  // $FlowFixMe[method-unbinding]
1086
1026
  var args = Array.prototype.slice.call(arguments);
@@ -1094,6 +1034,57 @@ function createServerReference(id, callServer, encodeFormAction) {
1094
1034
  return proxy;
1095
1035
  }
1096
1036
 
1037
+ var ContextRegistry = ReactSharedInternals.ContextRegistry;
1038
+ function getOrCreateServerContext(globalName) {
1039
+ if (!ContextRegistry[globalName]) {
1040
+ var context = {
1041
+ $$typeof: REACT_SERVER_CONTEXT_TYPE,
1042
+ // As a workaround to support multiple concurrent renderers, we categorize
1043
+ // some renderers as primary and others as secondary. We only expect
1044
+ // there to be two concurrent renderers at most: React Native (primary) and
1045
+ // Fabric (secondary); React DOM (primary) and React ART (secondary).
1046
+ // Secondary renderers store their context values on separate fields.
1047
+ _currentValue: REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED,
1048
+ _currentValue2: REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED,
1049
+ _defaultValue: REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED,
1050
+ // Used to track how many concurrent renderers this context currently
1051
+ // supports within in a single renderer. Such as parallel server rendering.
1052
+ _threadCount: 0,
1053
+ // These are circular
1054
+ Provider: null,
1055
+ Consumer: null,
1056
+ _globalName: globalName
1057
+ };
1058
+ context.Provider = {
1059
+ $$typeof: REACT_PROVIDER_TYPE,
1060
+ _context: context
1061
+ };
1062
+
1063
+ {
1064
+ var hasWarnedAboutUsingConsumer;
1065
+ context._currentRenderer = null;
1066
+ context._currentRenderer2 = null;
1067
+ Object.defineProperties(context, {
1068
+ Consumer: {
1069
+ get: function () {
1070
+ if (!hasWarnedAboutUsingConsumer) {
1071
+ error('Consumer pattern is not supported by ReactServerContext');
1072
+
1073
+ hasWarnedAboutUsingConsumer = true;
1074
+ }
1075
+
1076
+ return null;
1077
+ }
1078
+ }
1079
+ });
1080
+ }
1081
+
1082
+ ContextRegistry[globalName] = context;
1083
+ }
1084
+
1085
+ return ContextRegistry[globalName];
1086
+ }
1087
+
1097
1088
  var ROW_ID = 0;
1098
1089
  var ROW_TAG = 1;
1099
1090
  var ROW_LENGTH = 2;
@@ -1112,10 +1103,6 @@ function Chunk(status, value, reason, response) {
1112
1103
  this.value = value;
1113
1104
  this.reason = reason;
1114
1105
  this._response = response;
1115
-
1116
- {
1117
- this._debugInfo = null;
1118
- }
1119
1106
  } // We subclass Promise.prototype so that we get other methods like .catch
1120
1107
 
1121
1108
 
@@ -1392,20 +1379,17 @@ function reportGlobalError(response, error) {
1392
1379
  }
1393
1380
 
1394
1381
  function createElement(type, key, props) {
1395
- var element;
1396
-
1397
- {
1398
- element = {
1399
- // This tag allows us to uniquely identify this as a React Element
1400
- $$typeof: REACT_ELEMENT_TYPE,
1401
- type: type,
1402
- key: key,
1403
- ref: null,
1404
- props: props,
1405
- // Record the component responsible for creating this element.
1406
- _owner: null
1407
- };
1408
- }
1382
+ var element = {
1383
+ // This tag allows us to uniquely identify this as a React Element
1384
+ $$typeof: REACT_ELEMENT_TYPE,
1385
+ // Built-in properties that belong on the element
1386
+ type: type,
1387
+ key: key,
1388
+ ref: null,
1389
+ props: props,
1390
+ // Record the component responsible for creating this element.
1391
+ _owner: null
1392
+ };
1409
1393
 
1410
1394
  {
1411
1395
  // We don't really need to add any of these but keeping them for good measure.
@@ -1418,12 +1402,17 @@ function createElement(type, key, props) {
1418
1402
  writable: true,
1419
1403
  value: true // This element has already been validated on the server.
1420
1404
 
1421
- }); // debugInfo contains Server Component debug information.
1422
-
1423
- Object.defineProperty(element, '_debugInfo', {
1405
+ });
1406
+ Object.defineProperty(element, '_self', {
1424
1407
  configurable: false,
1425
1408
  enumerable: false,
1426
- writable: true,
1409
+ writable: false,
1410
+ value: null
1411
+ });
1412
+ Object.defineProperty(element, '_source', {
1413
+ configurable: false,
1414
+ enumerable: false,
1415
+ writable: false,
1427
1416
  value: null
1428
1417
  });
1429
1418
  }
@@ -1437,13 +1426,6 @@ function createLazyChunkWrapper(chunk) {
1437
1426
  _payload: chunk,
1438
1427
  _init: readChunk
1439
1428
  };
1440
-
1441
- {
1442
- // Ensure we have a live array to track future debug info.
1443
- var chunkDebugInfo = chunk._debugInfo || (chunk._debugInfo = []);
1444
- lazyType._debugInfo = chunkDebugInfo;
1445
- }
1446
-
1447
1429
  return lazyType;
1448
1430
  }
1449
1431
 
@@ -1579,11 +1561,6 @@ function parseModelString(response, parentObject, key, value) {
1579
1561
  case '@':
1580
1562
  {
1581
1563
  // Promise
1582
- if (value.length === 2) {
1583
- // Infinite promise that never resolves.
1584
- return new Promise(function () {});
1585
- }
1586
-
1587
1564
  var _id = parseInt(value.slice(2), 16);
1588
1565
 
1589
1566
  var _chunk = getChunk(response, _id);
@@ -1597,6 +1574,12 @@ function parseModelString(response, parentObject, key, value) {
1597
1574
  return Symbol.for(value.slice(2));
1598
1575
  }
1599
1576
 
1577
+ case 'P':
1578
+ {
1579
+ // Server Context Provider
1580
+ return getOrCreateServerContext(value.slice(2)).Provider;
1581
+ }
1582
+
1600
1583
  case 'F':
1601
1584
  {
1602
1585
  // Server Reference
@@ -1666,23 +1649,6 @@ function parseModelString(response, parentObject, key, value) {
1666
1649
  return BigInt(value.slice(2));
1667
1650
  }
1668
1651
 
1669
- case 'E':
1670
- {
1671
- {
1672
- // In DEV mode we allow indirect eval to produce functions for logging.
1673
- // This should not compile to eval() because then it has local scope access.
1674
- try {
1675
- // eslint-disable-next-line no-eval
1676
- return (0, eval)(value.slice(2));
1677
- } catch (x) {
1678
- // We currently use this to express functions so we fail parsing it,
1679
- // let's just return a blank function as a place holder.
1680
- return function () {};
1681
- }
1682
- } // Fallthrough
1683
-
1684
- }
1685
-
1686
1652
  default:
1687
1653
  {
1688
1654
  // We assume that anything else is a reference ID.
@@ -1703,29 +1669,7 @@ function parseModelString(response, parentObject, key, value) {
1703
1669
 
1704
1670
  switch (_chunk2.status) {
1705
1671
  case INITIALIZED:
1706
- var chunkValue = _chunk2.value;
1707
-
1708
- if (_chunk2._debugInfo) {
1709
- // If we have a direct reference to an object that was rendered by a synchronous
1710
- // server component, it might have some debug info about how it was rendered.
1711
- // We forward this to the underlying object. This might be a React Element or
1712
- // an Array fragment.
1713
- // If this was a string / number return value we lose the debug info. We choose
1714
- // that tradeoff to allow sync server components to return plain values and not
1715
- // use them as React Nodes necessarily. We could otherwise wrap them in a Lazy.
1716
- if (typeof chunkValue === 'object' && chunkValue !== null && (Array.isArray(chunkValue) || chunkValue.$$typeof === REACT_ELEMENT_TYPE) && !chunkValue._debugInfo) {
1717
- // We should maybe use a unique symbol for arrays but this is a React owned array.
1718
- // $FlowFixMe[prop-missing]: This should be added to elements.
1719
- Object.defineProperty(chunkValue, '_debugInfo', {
1720
- configurable: false,
1721
- enumerable: false,
1722
- writable: true,
1723
- value: _chunk2._debugInfo
1724
- });
1725
- }
1726
- }
1727
-
1728
- return chunkValue;
1672
+ return _chunk2.value;
1729
1673
 
1730
1674
  case PENDING:
1731
1675
  case BLOCKED:
@@ -1762,13 +1706,12 @@ function missingCall() {
1762
1706
  throw new Error('Trying to call a function from "use server" but the callServer option ' + 'was not implemented in your router runtime.');
1763
1707
  }
1764
1708
 
1765
- function createResponse(bundlerConfig, moduleLoading, callServer, encodeFormAction, nonce) {
1709
+ function createResponse(bundlerConfig, moduleLoading, callServer, nonce) {
1766
1710
  var chunks = new Map();
1767
1711
  var response = {
1768
1712
  _bundlerConfig: bundlerConfig,
1769
1713
  _moduleLoading: moduleLoading,
1770
1714
  _callServer: callServer !== undefined ? callServer : missingCall,
1771
- _encodeFormAction: encodeFormAction,
1772
1715
  _nonce: nonce,
1773
1716
  _chunks: chunks,
1774
1717
  _stringDecoder: createStringDecoder(),
@@ -1865,24 +1808,6 @@ function resolveHint(response, code, model) {
1865
1808
  dispatchHint(code, hintModel);
1866
1809
  }
1867
1810
 
1868
- function resolveDebugInfo(response, id, debugInfo) {
1869
-
1870
- var chunk = getChunk(response, id);
1871
- var chunkDebugInfo = chunk._debugInfo || (chunk._debugInfo = []);
1872
- chunkDebugInfo.push(debugInfo);
1873
- }
1874
-
1875
- function resolveConsoleEntry(response, value) {
1876
-
1877
- var payload = parseModel(response, value);
1878
- var methodName = payload[0]; // TODO: Restore the fake stack before logging.
1879
- // const stackTrace = payload[1];
1880
-
1881
- var env = payload[2];
1882
- var args = payload.slice(3);
1883
- printToConsole(methodName, args, env);
1884
- }
1885
-
1886
1811
  function processFullRow(response, id, tag, buffer, chunk) {
1887
1812
 
1888
1813
  var stringDecoder = response._stringDecoder;
@@ -1933,28 +1858,6 @@ function processFullRow(response, id, tag, buffer, chunk) {
1933
1858
  return;
1934
1859
  }
1935
1860
 
1936
- case 68
1937
- /* "D" */
1938
- :
1939
- {
1940
- {
1941
- var debugInfo = JSON.parse(row);
1942
- resolveDebugInfo(response, id, debugInfo);
1943
- return;
1944
- } // Fallthrough to share the error with Console entries.
1945
-
1946
- }
1947
-
1948
- case 87
1949
- /* "W" */
1950
- :
1951
- {
1952
- {
1953
- resolveConsoleEntry(response, row);
1954
- return;
1955
- }
1956
- }
1957
-
1958
1861
  case 80
1959
1862
  /* "P" */
1960
1863
  :
@@ -2132,8 +2035,7 @@ function close(response) {
2132
2035
  }
2133
2036
 
2134
2037
  function createResponseFromOptions(options) {
2135
- return createResponse(null, null, options && options.callServer ? options.callServer : undefined, undefined, // encodeFormAction
2136
- undefined // nonce
2038
+ return createResponse(null, null, options && options.callServer ? options.callServer : undefined, undefined // nonce
2137
2039
  );
2138
2040
  }
2139
2041
 
@@ -11,6 +11,7 @@
11
11
  'use strict';
12
12
 
13
13
  var ReactDOM = require('react-dom');
14
+ var React = require('react');
14
15
 
15
16
  // -----------------------------------------------------------------------------
16
17
  const enableBinaryFlight = false;
@@ -324,7 +325,10 @@ function refineModel(code, model) {
324
325
  // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
325
326
  // The Symbol used to tag the ReactElement-like types.
326
327
  const REACT_ELEMENT_TYPE = Symbol.for('react.element');
328
+ const REACT_PROVIDER_TYPE = Symbol.for('react.provider');
329
+ const REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
327
330
  const REACT_LAZY_TYPE = Symbol.for('react.lazy');
331
+ const REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
328
332
  const MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
329
333
  const FAUX_ITERATOR_SYMBOL = '@@iterator';
330
334
  function getIteratorFn(maybeIterable) {
@@ -617,12 +621,12 @@ function processReply(root, formFieldPrefix, resolve, reject) {
617
621
  }
618
622
  }
619
623
 
620
- function registerServerReference(proxy, reference, encodeFormAction) {
624
+ function registerServerReference(proxy, reference) {
621
625
 
622
626
  knownServerReferences.set(proxy, reference);
623
627
  } // $FlowFixMe[method-unbinding]
624
628
 
625
- function createServerReference(id, callServer, encodeFormAction) {
629
+ function createServerReference(id, callServer) {
626
630
  const proxy = function () {
627
631
  // $FlowFixMe[method-unbinding]
628
632
  const args = Array.prototype.slice.call(arguments);
@@ -636,6 +640,40 @@ function createServerReference(id, callServer, encodeFormAction) {
636
640
  return proxy;
637
641
  }
638
642
 
643
+ const ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
644
+
645
+ const ContextRegistry = ReactSharedInternals.ContextRegistry;
646
+ function getOrCreateServerContext(globalName) {
647
+ if (!ContextRegistry[globalName]) {
648
+ const context = {
649
+ $$typeof: REACT_SERVER_CONTEXT_TYPE,
650
+ // As a workaround to support multiple concurrent renderers, we categorize
651
+ // some renderers as primary and others as secondary. We only expect
652
+ // there to be two concurrent renderers at most: React Native (primary) and
653
+ // Fabric (secondary); React DOM (primary) and React ART (secondary).
654
+ // Secondary renderers store their context values on separate fields.
655
+ _currentValue: REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED,
656
+ _currentValue2: REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED,
657
+ _defaultValue: REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED,
658
+ // Used to track how many concurrent renderers this context currently
659
+ // supports within in a single renderer. Such as parallel server rendering.
660
+ _threadCount: 0,
661
+ // These are circular
662
+ Provider: null,
663
+ Consumer: null,
664
+ _globalName: globalName
665
+ };
666
+ context.Provider = {
667
+ $$typeof: REACT_PROVIDER_TYPE,
668
+ _context: context
669
+ };
670
+
671
+ ContextRegistry[globalName] = context;
672
+ }
673
+
674
+ return ContextRegistry[globalName];
675
+ }
676
+
639
677
  const ROW_ID = 0;
640
678
  const ROW_TAG = 1;
641
679
  const ROW_LENGTH = 2;
@@ -930,20 +968,17 @@ function reportGlobalError(response, error) {
930
968
  }
931
969
 
932
970
  function createElement(type, key, props) {
933
- let element;
934
-
935
- {
936
- element = {
937
- // This tag allows us to uniquely identify this as a React Element
938
- $$typeof: REACT_ELEMENT_TYPE,
939
- type,
940
- key,
941
- ref: null,
942
- props,
943
- // Record the component responsible for creating this element.
944
- _owner: null
945
- };
946
- }
971
+ const element = {
972
+ // This tag allows us to uniquely identify this as a React Element
973
+ $$typeof: REACT_ELEMENT_TYPE,
974
+ // Built-in properties that belong on the element
975
+ type: type,
976
+ key: key,
977
+ ref: null,
978
+ props: props,
979
+ // Record the component responsible for creating this element.
980
+ _owner: null
981
+ };
947
982
 
948
983
  return element;
949
984
  }
@@ -954,7 +989,6 @@ function createLazyChunkWrapper(chunk) {
954
989
  _payload: chunk,
955
990
  _init: readChunk
956
991
  };
957
-
958
992
  return lazyType;
959
993
  }
960
994
 
@@ -1088,11 +1122,6 @@ function parseModelString(response, parentObject, key, value) {
1088
1122
  case '@':
1089
1123
  {
1090
1124
  // Promise
1091
- if (value.length === 2) {
1092
- // Infinite promise that never resolves.
1093
- return new Promise(() => {});
1094
- }
1095
-
1096
1125
  const id = parseInt(value.slice(2), 16);
1097
1126
  const chunk = getChunk(response, id);
1098
1127
  return chunk;
@@ -1104,6 +1133,12 @@ function parseModelString(response, parentObject, key, value) {
1104
1133
  return Symbol.for(value.slice(2));
1105
1134
  }
1106
1135
 
1136
+ case 'P':
1137
+ {
1138
+ // Server Context Provider
1139
+ return getOrCreateServerContext(value.slice(2)).Provider;
1140
+ }
1141
+
1107
1142
  case 'F':
1108
1143
  {
1109
1144
  // Server Reference
@@ -1169,8 +1204,6 @@ function parseModelString(response, parentObject, key, value) {
1169
1204
  return BigInt(value.slice(2));
1170
1205
  }
1171
1206
 
1172
- case 'E':
1173
-
1174
1207
  default:
1175
1208
  {
1176
1209
  // We assume that anything else is a reference ID.
@@ -1190,9 +1223,7 @@ function parseModelString(response, parentObject, key, value) {
1190
1223
 
1191
1224
  switch (chunk.status) {
1192
1225
  case INITIALIZED:
1193
- const chunkValue = chunk.value;
1194
-
1195
- return chunkValue;
1226
+ return chunk.value;
1196
1227
 
1197
1228
  case PENDING:
1198
1229
  case BLOCKED:
@@ -1227,13 +1258,12 @@ function missingCall() {
1227
1258
  throw new Error('Trying to call a function from "use server" but the callServer option ' + 'was not implemented in your router runtime.');
1228
1259
  }
1229
1260
 
1230
- function createResponse(bundlerConfig, moduleLoading, callServer, encodeFormAction, nonce) {
1261
+ function createResponse(bundlerConfig, moduleLoading, callServer, nonce) {
1231
1262
  const chunks = new Map();
1232
1263
  const response = {
1233
1264
  _bundlerConfig: bundlerConfig,
1234
1265
  _moduleLoading: moduleLoading,
1235
1266
  _callServer: callServer !== undefined ? callServer : missingCall,
1236
- _encodeFormAction: encodeFormAction,
1237
1267
  _nonce: nonce,
1238
1268
  _chunks: chunks,
1239
1269
  _stringDecoder: createStringDecoder(),
@@ -1375,18 +1405,6 @@ function processFullRow(response, id, tag, buffer, chunk) {
1375
1405
  return;
1376
1406
  }
1377
1407
 
1378
- case 68
1379
- /* "D" */
1380
- :
1381
-
1382
- case 87
1383
- /* "W" */
1384
- :
1385
- {
1386
-
1387
- throw new Error('Failed to read a RSC payload created by a development version of React ' + 'on the server while using a production version on the client. Always use ' + 'matching versions on the server and the client.');
1388
- }
1389
-
1390
1408
  case 80
1391
1409
  /* "P" */
1392
1410
  :
@@ -1563,8 +1581,7 @@ function close(response) {
1563
1581
  }
1564
1582
 
1565
1583
  function createResponseFromOptions(options) {
1566
- return createResponse(null, null, options && options.callServer ? options.callServer : undefined, undefined, // encodeFormAction
1567
- undefined // nonce
1584
+ return createResponse(null, null, options && options.callServer ? options.callServer : undefined, undefined // nonce
1568
1585
  );
1569
1586
  }
1570
1587