react-server-dom-webpack 19.0.0-rc-a532d91d01-20240610 → 19.0.0-rc-34d0c5e357-20240607

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.
@@ -10,21 +10,7 @@
10
10
 
11
11
  "use strict";
12
12
  var ReactDOM = require("react-dom"),
13
- React = require("react");
14
- function handleErrorInNextTick(error) {
15
- setTimeout(function () {
16
- throw error;
17
- });
18
- }
19
- var LocalPromise = Promise,
20
- scheduleMicrotask =
21
- "function" === typeof queueMicrotask
22
- ? queueMicrotask
23
- : function (callback) {
24
- LocalPromise.resolve(null)
25
- .then(callback)
26
- .catch(handleErrorInNextTick);
27
- },
13
+ React = require("react"),
28
14
  currentView = null,
29
15
  writtenBytes = 0;
30
16
  function writeChunkAndReturn(destination, chunk) {
@@ -691,8 +677,7 @@ if (!ReactSharedInternalsServer)
691
677
  '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.'
692
678
  );
693
679
  var ObjectPrototype = Object.prototype,
694
- stringify = JSON.stringify,
695
- AbortSigil = {};
680
+ stringify = JSON.stringify;
696
681
  function defaultErrorHandler(error) {
697
682
  console.error(error);
698
683
  }
@@ -776,14 +761,6 @@ function serializeThenable(request, task, thenable) {
776
761
  newTask.id
777
762
  );
778
763
  default:
779
- if (1 === request.status)
780
- return (
781
- (newTask.status = 3),
782
- (task = stringify(serializeByValueID(request.fatalError))),
783
- emitModelChunk(request, newTask.id, task),
784
- request.abortableTasks.delete(newTask),
785
- newTask.id
786
- );
787
764
  "string" !== typeof thenable.status &&
788
765
  ((thenable.status = "pending"),
789
766
  thenable.then(
@@ -970,12 +947,7 @@ function renderFunctionComponent(request, task, key, Component, props) {
970
947
  thenableIndexCounter = 0;
971
948
  thenableState = prevThenableState;
972
949
  Component = Component(props, void 0);
973
- if (1 === request.status) throw AbortSigil;
974
- if (
975
- "object" === typeof Component &&
976
- null !== Component &&
977
- Component.$$typeof !== CLIENT_REFERENCE_TAG$1
978
- ) {
950
+ if ("object" === typeof Component && null !== Component) {
979
951
  if ("function" === typeof Component.then) {
980
952
  props = Component;
981
953
  if ("fulfilled" === props.status) return props.value;
@@ -1068,7 +1040,6 @@ function renderElement(request, task, type, key, ref, props) {
1068
1040
  case REACT_LAZY_TYPE:
1069
1041
  var init = type._init;
1070
1042
  type = init(type._payload);
1071
- if (1 === request.status) throw AbortSigil;
1072
1043
  return renderElement(request, task, type, key, ref, props);
1073
1044
  case REACT_FORWARD_REF_TYPE:
1074
1045
  return renderFunctionComponent(request, task, key, type.render, props);
@@ -1085,9 +1056,9 @@ function pingTask(request, task) {
1085
1056
  pingedTasks.push(task);
1086
1057
  1 === pingedTasks.length &&
1087
1058
  ((request.flushScheduled = null !== request.destination),
1088
- scheduleMicrotask(function () {
1059
+ setTimeout(function () {
1089
1060
  return performWork(request);
1090
- }));
1061
+ }, 0));
1091
1062
  }
1092
1063
  function createTask(request, model, keyPath, implicitSlot, abortSet) {
1093
1064
  request.pendingChunks++;
@@ -1119,61 +1090,50 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1119
1090
  );
1120
1091
  } catch (thrownValue) {
1121
1092
  if (
1122
- ((parentPropertyName = task.model),
1123
- (parentPropertyName =
1124
- "object" === typeof parentPropertyName &&
1125
- null !== parentPropertyName &&
1126
- (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1127
- parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1128
- (value =
1093
+ ((parentPropertyName =
1129
1094
  thrownValue === SuspenseException
1130
1095
  ? getSuspendedThenable()
1131
1096
  : thrownValue),
1132
- "object" === typeof value &&
1097
+ (value = task.model),
1098
+ (value =
1099
+ "object" === typeof value &&
1133
1100
  null !== value &&
1134
- "function" === typeof value.then)
1135
- )
1136
- if (1 === request.status)
1137
- (task.status = 3),
1138
- (prevKeyPath = request.fatalError),
1139
- (JSCompiler_inline_result = parentPropertyName
1140
- ? "$L" + prevKeyPath.toString(16)
1141
- : serializeByValueID(prevKeyPath));
1142
- else {
1143
- JSCompiler_inline_result = createTask(
1144
- request,
1145
- task.model,
1146
- task.keyPath,
1147
- task.implicitSlot,
1148
- request.abortableTasks
1149
- );
1150
- var ping = JSCompiler_inline_result.ping;
1151
- value.then(ping, ping);
1152
- JSCompiler_inline_result.thenableState =
1153
- getThenableStateAfterSuspending();
1154
- task.keyPath = prevKeyPath;
1155
- task.implicitSlot = prevImplicitSlot;
1156
- JSCompiler_inline_result = parentPropertyName
1157
- ? "$L" + JSCompiler_inline_result.id.toString(16)
1158
- : serializeByValueID(JSCompiler_inline_result.id);
1159
- }
1160
- else if (thrownValue === AbortSigil)
1161
- (task.status = 3),
1162
- (prevKeyPath = request.fatalError),
1163
- (JSCompiler_inline_result = parentPropertyName
1164
- ? "$L" + prevKeyPath.toString(16)
1165
- : serializeByValueID(prevKeyPath));
1166
- else if (
1101
+ (value.$$typeof === REACT_ELEMENT_TYPE ||
1102
+ value.$$typeof === REACT_LAZY_TYPE)),
1103
+ "object" === typeof parentPropertyName &&
1104
+ null !== parentPropertyName &&
1105
+ "function" === typeof parentPropertyName.then)
1106
+ ) {
1107
+ JSCompiler_inline_result = createTask(
1108
+ request,
1109
+ task.model,
1110
+ task.keyPath,
1111
+ task.implicitSlot,
1112
+ request.abortableTasks
1113
+ );
1114
+ var ping = JSCompiler_inline_result.ping;
1115
+ parentPropertyName.then(ping, ping);
1116
+ JSCompiler_inline_result.thenableState =
1117
+ getThenableStateAfterSuspending();
1118
+ task.keyPath = prevKeyPath;
1119
+ task.implicitSlot = prevImplicitSlot;
1120
+ JSCompiler_inline_result = value
1121
+ ? "$L" + JSCompiler_inline_result.id.toString(16)
1122
+ : serializeByValueID(JSCompiler_inline_result.id);
1123
+ } else if (
1167
1124
  ((task.keyPath = prevKeyPath),
1168
1125
  (task.implicitSlot = prevImplicitSlot),
1169
- parentPropertyName)
1126
+ value)
1170
1127
  )
1171
1128
  request.pendingChunks++,
1172
1129
  (prevKeyPath = request.nextChunkId++),
1173
- (prevImplicitSlot = logRecoverableError(request, value)),
1130
+ (prevImplicitSlot = logRecoverableError(
1131
+ request,
1132
+ parentPropertyName
1133
+ )),
1174
1134
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1175
1135
  (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1176
- else throw value;
1136
+ else throw parentPropertyName;
1177
1137
  }
1178
1138
  return JSCompiler_inline_result;
1179
1139
  },
@@ -1326,11 +1286,12 @@ function renderModelDestructive(
1326
1286
  parentPropertyName
1327
1287
  );
1328
1288
  case REACT_LAZY_TYPE:
1329
- task.thenableState = null;
1330
- parentPropertyName = value._init;
1331
- value = parentPropertyName(value._payload);
1332
- if (1 === request.status) throw AbortSigil;
1333
- return renderModelDestructive(request, task, emptyRoot, "", value);
1289
+ return (
1290
+ (task.thenableState = null),
1291
+ (parentPropertyName = value._init),
1292
+ (value = parentPropertyName(value._payload)),
1293
+ renderModelDestructive(request, task, emptyRoot, "", value)
1294
+ );
1334
1295
  case REACT_LEGACY_ELEMENT_TYPE:
1335
1296
  throw Error(
1336
1297
  'A React Element from an older version of React was rendered. This is not supported. It can happen if:\n- Multiple copies of the "react" package is used.\n- A library pre-bundled an old copy of "react" or "react/jsx-runtime".\n- A compiler tries to "inline" JSX instead of using the runtime.'
@@ -1593,8 +1554,8 @@ function logRecoverableError(request, error) {
1593
1554
  }
1594
1555
  function fatalError(request, error) {
1595
1556
  null !== request.destination
1596
- ? ((request.status = 3), closeWithError(request.destination, error))
1597
- : ((request.status = 2), (request.fatalError = error));
1557
+ ? ((request.status = 2), closeWithError(request.destination, error))
1558
+ : ((request.status = 1), (request.fatalError = error));
1598
1559
  }
1599
1560
  function emitErrorChunk(request, id, digest) {
1600
1561
  digest = { digest: digest };
@@ -1663,8 +1624,7 @@ function emitChunk(request, task, value) {
1663
1624
  }
1664
1625
  var emptyRoot = {};
1665
1626
  function retryTask(request, task) {
1666
- if (0 === task.status) {
1667
- task.status = 5;
1627
+ if (0 === task.status)
1668
1628
  try {
1669
1629
  modelRoot = task.model;
1670
1630
  var resolvedModel = renderModelDestructive(
@@ -1691,23 +1651,10 @@ function retryTask(request, task) {
1691
1651
  thrownValue === SuspenseException
1692
1652
  ? getSuspendedThenable()
1693
1653
  : thrownValue;
1694
- if ("object" === typeof x && null !== x && "function" === typeof x.then)
1695
- if (1 === request.status) {
1696
- request.abortableTasks.delete(task);
1697
- task.status = 3;
1698
- var model = stringify(serializeByValueID(request.fatalError));
1699
- emitModelChunk(request, task.id, model);
1700
- } else {
1701
- task.status = 0;
1702
- task.thenableState = getThenableStateAfterSuspending();
1703
- var ping = task.ping;
1704
- x.then(ping, ping);
1705
- }
1706
- else if (x === AbortSigil) {
1707
- request.abortableTasks.delete(task);
1708
- task.status = 3;
1709
- var model$19 = stringify(serializeByValueID(request.fatalError));
1710
- emitModelChunk(request, task.id, model$19);
1654
+ if ("object" === typeof x && null !== x && "function" === typeof x.then) {
1655
+ var ping = task.ping;
1656
+ x.then(ping, ping);
1657
+ task.thenableState = getThenableStateAfterSuspending();
1711
1658
  } else {
1712
1659
  request.abortableTasks.delete(task);
1713
1660
  task.status = 4;
@@ -1716,7 +1663,6 @@ function retryTask(request, task) {
1716
1663
  }
1717
1664
  } finally {
1718
1665
  }
1719
- }
1720
1666
  }
1721
1667
  function performWork(request) {
1722
1668
  var prevDispatcher = ReactSharedInternalsServer.H;
@@ -1774,7 +1720,7 @@ function flushCompletedChunks(request, destination) {
1774
1720
  (writtenBytes = 0));
1775
1721
  }
1776
1722
  0 === request.pendingChunks &&
1777
- ((request.status = 3), destination.close(), (request.destination = null));
1723
+ (destination.close(), (request.destination = null));
1778
1724
  }
1779
1725
  function startWork(request) {
1780
1726
  request.flushScheduled = null !== request.destination;
@@ -1787,63 +1733,53 @@ function startWork(request) {
1787
1733
  }, 0);
1788
1734
  }
1789
1735
  function enqueueFlush(request) {
1790
- !1 === request.flushScheduled &&
1736
+ if (
1737
+ !1 === request.flushScheduled &&
1791
1738
  0 === request.pingedTasks.length &&
1792
- null !== request.destination &&
1793
- ((request.flushScheduled = !0),
1739
+ null !== request.destination
1740
+ ) {
1741
+ var destination = request.destination;
1742
+ request.flushScheduled = !0;
1794
1743
  setTimeout(function () {
1795
- request.flushScheduled = !1;
1796
- var destination = request.destination;
1797
- destination && flushCompletedChunks(request, destination);
1798
- }, 0));
1744
+ return flushCompletedChunks(request, destination);
1745
+ }, 0);
1746
+ }
1799
1747
  }
1800
1748
  function abort(request, reason) {
1801
1749
  try {
1802
- request.status = 1;
1803
1750
  var abortableTasks = request.abortableTasks;
1804
1751
  if (0 < abortableTasks.size) {
1805
1752
  request.pendingChunks++;
1806
- var errorId = request.nextChunkId++;
1807
- request.fatalError = errorId;
1808
- var error =
1753
+ var errorId = request.nextChunkId++,
1754
+ error =
1809
1755
  void 0 === reason
1810
1756
  ? Error("The render was aborted by the server without a reason.")
1811
- : "object" === typeof reason &&
1812
- null !== reason &&
1813
- "function" === typeof reason.then
1814
- ? Error("The render was aborted by the server with a promise.")
1815
1757
  : reason,
1816
1758
  digest = logRecoverableError(request, error);
1817
1759
  emitErrorChunk(request, errorId, digest, error);
1818
1760
  abortableTasks.forEach(function (task) {
1819
- if (5 !== task.status) {
1820
- task.status = 3;
1821
- var ref = serializeByValueID(errorId);
1822
- task = encodeReferenceChunk(request, task.id, ref);
1823
- request.completedErrorChunks.push(task);
1824
- }
1761
+ task.status = 3;
1762
+ var ref = serializeByValueID(errorId);
1763
+ task = encodeReferenceChunk(request, task.id, ref);
1764
+ request.completedErrorChunks.push(task);
1825
1765
  });
1826
1766
  abortableTasks.clear();
1827
1767
  }
1828
1768
  var abortListeners = request.abortListeners;
1829
1769
  if (0 < abortListeners.size) {
1830
- var error$26 =
1770
+ var error$22 =
1831
1771
  void 0 === reason
1832
1772
  ? Error("The render was aborted by the server without a reason.")
1833
- : "object" === typeof reason &&
1834
- null !== reason &&
1835
- "function" === typeof reason.then
1836
- ? Error("The render was aborted by the server with a promise.")
1837
1773
  : reason;
1838
1774
  abortListeners.forEach(function (callback) {
1839
- return callback(error$26);
1775
+ return callback(error$22);
1840
1776
  });
1841
1777
  abortListeners.clear();
1842
1778
  }
1843
1779
  null !== request.destination &&
1844
1780
  flushCompletedChunks(request, request.destination);
1845
- } catch (error$27) {
1846
- logRecoverableError(request, error$27), fatalError(request, error$27);
1781
+ } catch (error$23) {
1782
+ logRecoverableError(request, error$23), fatalError(request, error$23);
1847
1783
  }
1848
1784
  }
1849
1785
  function resolveServerReference(bundlerConfig, id) {
@@ -2286,8 +2222,8 @@ function parseReadableStream(response, reference, type) {
2286
2222
  (previousBlockedChunk = chunk));
2287
2223
  } else {
2288
2224
  chunk = previousBlockedChunk;
2289
- var chunk$30 = createPendingChunk(response);
2290
- chunk$30.then(
2225
+ var chunk$26 = createPendingChunk(response);
2226
+ chunk$26.then(
2291
2227
  function (v) {
2292
2228
  return controller.enqueue(v);
2293
2229
  },
@@ -2295,10 +2231,10 @@ function parseReadableStream(response, reference, type) {
2295
2231
  return controller.error(e);
2296
2232
  }
2297
2233
  );
2298
- previousBlockedChunk = chunk$30;
2234
+ previousBlockedChunk = chunk$26;
2299
2235
  chunk.then(function () {
2300
- previousBlockedChunk === chunk$30 && (previousBlockedChunk = null);
2301
- resolveModelChunk(chunk$30, json, -1);
2236
+ previousBlockedChunk === chunk$26 && (previousBlockedChunk = null);
2237
+ resolveModelChunk(chunk$26, json, -1);
2302
2238
  });
2303
2239
  }
2304
2240
  },
@@ -2666,9 +2602,9 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
2666
2602
  startWork(request);
2667
2603
  },
2668
2604
  pull: function (controller) {
2669
- if (2 === request.status)
2670
- (request.status = 3), closeWithError(controller, request.fatalError);
2671
- else if (3 !== request.status && null === request.destination) {
2605
+ if (1 === request.status)
2606
+ (request.status = 2), closeWithError(controller, request.fatalError);
2607
+ else if (2 !== request.status && null === request.destination) {
2672
2608
  request.destination = controller;
2673
2609
  try {
2674
2610
  flushCompletedChunks(request, controller);