react-server-dom-webpack 19.0.0-rc-a532d91d01-20240610 → 19.0.0-rc-6230622a1a-20240610

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,7 +947,6 @@ 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
950
  if (
975
951
  "object" === typeof Component &&
976
952
  null !== Component &&
@@ -1068,7 +1044,6 @@ function renderElement(request, task, type, key, ref, props) {
1068
1044
  case REACT_LAZY_TYPE:
1069
1045
  var init = type._init;
1070
1046
  type = init(type._payload);
1071
- if (1 === request.status) throw AbortSigil;
1072
1047
  return renderElement(request, task, type, key, ref, props);
1073
1048
  case REACT_FORWARD_REF_TYPE:
1074
1049
  return renderFunctionComponent(request, task, key, type.render, props);
@@ -1085,9 +1060,9 @@ function pingTask(request, task) {
1085
1060
  pingedTasks.push(task);
1086
1061
  1 === pingedTasks.length &&
1087
1062
  ((request.flushScheduled = null !== request.destination),
1088
- scheduleMicrotask(function () {
1063
+ setTimeout(function () {
1089
1064
  return performWork(request);
1090
- }));
1065
+ }, 0));
1091
1066
  }
1092
1067
  function createTask(request, model, keyPath, implicitSlot, abortSet) {
1093
1068
  request.pendingChunks++;
@@ -1119,61 +1094,50 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1119
1094
  );
1120
1095
  } catch (thrownValue) {
1121
1096
  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 =
1097
+ ((parentPropertyName =
1129
1098
  thrownValue === SuspenseException
1130
1099
  ? getSuspendedThenable()
1131
1100
  : thrownValue),
1132
- "object" === typeof value &&
1101
+ (value = task.model),
1102
+ (value =
1103
+ "object" === typeof value &&
1133
1104
  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 (
1105
+ (value.$$typeof === REACT_ELEMENT_TYPE ||
1106
+ value.$$typeof === REACT_LAZY_TYPE)),
1107
+ "object" === typeof parentPropertyName &&
1108
+ null !== parentPropertyName &&
1109
+ "function" === typeof parentPropertyName.then)
1110
+ ) {
1111
+ JSCompiler_inline_result = createTask(
1112
+ request,
1113
+ task.model,
1114
+ task.keyPath,
1115
+ task.implicitSlot,
1116
+ request.abortableTasks
1117
+ );
1118
+ var ping = JSCompiler_inline_result.ping;
1119
+ parentPropertyName.then(ping, ping);
1120
+ JSCompiler_inline_result.thenableState =
1121
+ getThenableStateAfterSuspending();
1122
+ task.keyPath = prevKeyPath;
1123
+ task.implicitSlot = prevImplicitSlot;
1124
+ JSCompiler_inline_result = value
1125
+ ? "$L" + JSCompiler_inline_result.id.toString(16)
1126
+ : serializeByValueID(JSCompiler_inline_result.id);
1127
+ } else if (
1167
1128
  ((task.keyPath = prevKeyPath),
1168
1129
  (task.implicitSlot = prevImplicitSlot),
1169
- parentPropertyName)
1130
+ value)
1170
1131
  )
1171
1132
  request.pendingChunks++,
1172
1133
  (prevKeyPath = request.nextChunkId++),
1173
- (prevImplicitSlot = logRecoverableError(request, value)),
1134
+ (prevImplicitSlot = logRecoverableError(
1135
+ request,
1136
+ parentPropertyName
1137
+ )),
1174
1138
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1175
1139
  (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1176
- else throw value;
1140
+ else throw parentPropertyName;
1177
1141
  }
1178
1142
  return JSCompiler_inline_result;
1179
1143
  },
@@ -1326,11 +1290,12 @@ function renderModelDestructive(
1326
1290
  parentPropertyName
1327
1291
  );
1328
1292
  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);
1293
+ return (
1294
+ (task.thenableState = null),
1295
+ (parentPropertyName = value._init),
1296
+ (value = parentPropertyName(value._payload)),
1297
+ renderModelDestructive(request, task, emptyRoot, "", value)
1298
+ );
1334
1299
  case REACT_LEGACY_ELEMENT_TYPE:
1335
1300
  throw Error(
1336
1301
  '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 +1558,8 @@ function logRecoverableError(request, error) {
1593
1558
  }
1594
1559
  function fatalError(request, error) {
1595
1560
  null !== request.destination
1596
- ? ((request.status = 3), closeWithError(request.destination, error))
1597
- : ((request.status = 2), (request.fatalError = error));
1561
+ ? ((request.status = 2), closeWithError(request.destination, error))
1562
+ : ((request.status = 1), (request.fatalError = error));
1598
1563
  }
1599
1564
  function emitErrorChunk(request, id, digest) {
1600
1565
  digest = { digest: digest };
@@ -1663,8 +1628,7 @@ function emitChunk(request, task, value) {
1663
1628
  }
1664
1629
  var emptyRoot = {};
1665
1630
  function retryTask(request, task) {
1666
- if (0 === task.status) {
1667
- task.status = 5;
1631
+ if (0 === task.status)
1668
1632
  try {
1669
1633
  modelRoot = task.model;
1670
1634
  var resolvedModel = renderModelDestructive(
@@ -1691,23 +1655,10 @@ function retryTask(request, task) {
1691
1655
  thrownValue === SuspenseException
1692
1656
  ? getSuspendedThenable()
1693
1657
  : 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);
1658
+ if ("object" === typeof x && null !== x && "function" === typeof x.then) {
1659
+ var ping = task.ping;
1660
+ x.then(ping, ping);
1661
+ task.thenableState = getThenableStateAfterSuspending();
1711
1662
  } else {
1712
1663
  request.abortableTasks.delete(task);
1713
1664
  task.status = 4;
@@ -1716,7 +1667,6 @@ function retryTask(request, task) {
1716
1667
  }
1717
1668
  } finally {
1718
1669
  }
1719
- }
1720
1670
  }
1721
1671
  function performWork(request) {
1722
1672
  var prevDispatcher = ReactSharedInternalsServer.H;
@@ -1774,7 +1724,7 @@ function flushCompletedChunks(request, destination) {
1774
1724
  (writtenBytes = 0));
1775
1725
  }
1776
1726
  0 === request.pendingChunks &&
1777
- ((request.status = 3), destination.close(), (request.destination = null));
1727
+ (destination.close(), (request.destination = null));
1778
1728
  }
1779
1729
  function startWork(request) {
1780
1730
  request.flushScheduled = null !== request.destination;
@@ -1787,63 +1737,53 @@ function startWork(request) {
1787
1737
  }, 0);
1788
1738
  }
1789
1739
  function enqueueFlush(request) {
1790
- !1 === request.flushScheduled &&
1740
+ if (
1741
+ !1 === request.flushScheduled &&
1791
1742
  0 === request.pingedTasks.length &&
1792
- null !== request.destination &&
1793
- ((request.flushScheduled = !0),
1743
+ null !== request.destination
1744
+ ) {
1745
+ var destination = request.destination;
1746
+ request.flushScheduled = !0;
1794
1747
  setTimeout(function () {
1795
- request.flushScheduled = !1;
1796
- var destination = request.destination;
1797
- destination && flushCompletedChunks(request, destination);
1798
- }, 0));
1748
+ return flushCompletedChunks(request, destination);
1749
+ }, 0);
1750
+ }
1799
1751
  }
1800
1752
  function abort(request, reason) {
1801
1753
  try {
1802
- request.status = 1;
1803
1754
  var abortableTasks = request.abortableTasks;
1804
1755
  if (0 < abortableTasks.size) {
1805
1756
  request.pendingChunks++;
1806
- var errorId = request.nextChunkId++;
1807
- request.fatalError = errorId;
1808
- var error =
1757
+ var errorId = request.nextChunkId++,
1758
+ error =
1809
1759
  void 0 === reason
1810
1760
  ? 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
1761
  : reason,
1816
1762
  digest = logRecoverableError(request, error);
1817
1763
  emitErrorChunk(request, errorId, digest, error);
1818
1764
  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
- }
1765
+ task.status = 3;
1766
+ var ref = serializeByValueID(errorId);
1767
+ task = encodeReferenceChunk(request, task.id, ref);
1768
+ request.completedErrorChunks.push(task);
1825
1769
  });
1826
1770
  abortableTasks.clear();
1827
1771
  }
1828
1772
  var abortListeners = request.abortListeners;
1829
1773
  if (0 < abortListeners.size) {
1830
- var error$26 =
1774
+ var error$22 =
1831
1775
  void 0 === reason
1832
1776
  ? 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
1777
  : reason;
1838
1778
  abortListeners.forEach(function (callback) {
1839
- return callback(error$26);
1779
+ return callback(error$22);
1840
1780
  });
1841
1781
  abortListeners.clear();
1842
1782
  }
1843
1783
  null !== request.destination &&
1844
1784
  flushCompletedChunks(request, request.destination);
1845
- } catch (error$27) {
1846
- logRecoverableError(request, error$27), fatalError(request, error$27);
1785
+ } catch (error$23) {
1786
+ logRecoverableError(request, error$23), fatalError(request, error$23);
1847
1787
  }
1848
1788
  }
1849
1789
  function resolveServerReference(bundlerConfig, id) {
@@ -2286,8 +2226,8 @@ function parseReadableStream(response, reference, type) {
2286
2226
  (previousBlockedChunk = chunk));
2287
2227
  } else {
2288
2228
  chunk = previousBlockedChunk;
2289
- var chunk$30 = createPendingChunk(response);
2290
- chunk$30.then(
2229
+ var chunk$26 = createPendingChunk(response);
2230
+ chunk$26.then(
2291
2231
  function (v) {
2292
2232
  return controller.enqueue(v);
2293
2233
  },
@@ -2295,10 +2235,10 @@ function parseReadableStream(response, reference, type) {
2295
2235
  return controller.error(e);
2296
2236
  }
2297
2237
  );
2298
- previousBlockedChunk = chunk$30;
2238
+ previousBlockedChunk = chunk$26;
2299
2239
  chunk.then(function () {
2300
- previousBlockedChunk === chunk$30 && (previousBlockedChunk = null);
2301
- resolveModelChunk(chunk$30, json, -1);
2240
+ previousBlockedChunk === chunk$26 && (previousBlockedChunk = null);
2241
+ resolveModelChunk(chunk$26, json, -1);
2302
2242
  });
2303
2243
  }
2304
2244
  },
@@ -2666,9 +2606,9 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
2666
2606
  startWork(request);
2667
2607
  },
2668
2608
  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) {
2609
+ if (1 === request.status)
2610
+ (request.status = 2), closeWithError(controller, request.fatalError);
2611
+ else if (2 !== request.status && null === request.destination) {
2672
2612
  request.destination = controller;
2673
2613
  try {
2674
2614
  flushCompletedChunks(request, controller);