react-server-dom-webpack 19.0.0-rc-20b6f4c0e8-20240607 → 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.
@@ -14,7 +14,6 @@ require("crypto");
14
14
  var async_hooks = require("async_hooks"),
15
15
  ReactDOM = require("react-dom"),
16
16
  React = require("react"),
17
- scheduleMicrotask = queueMicrotask,
18
17
  currentView = null,
19
18
  writtenBytes = 0,
20
19
  destinationHasCapacity = !0;
@@ -708,8 +707,7 @@ if (!ReactSharedInternalsServer)
708
707
  '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.'
709
708
  );
710
709
  var ObjectPrototype = Object.prototype,
711
- stringify = JSON.stringify,
712
- AbortSigil = {};
710
+ stringify = JSON.stringify;
713
711
  function defaultErrorHandler(error) {
714
712
  console.error(error);
715
713
  }
@@ -790,14 +788,6 @@ function serializeThenable(request, task, thenable) {
790
788
  newTask.id
791
789
  );
792
790
  default:
793
- if (1 === request.status)
794
- return (
795
- (newTask.status = 3),
796
- (task = stringify(serializeByValueID(request.fatalError))),
797
- emitModelChunk(request, newTask.id, task),
798
- request.abortableTasks.delete(newTask),
799
- newTask.id
800
- );
801
791
  "string" !== typeof thenable.status &&
802
792
  ((thenable.status = "pending"),
803
793
  thenable.then(
@@ -983,12 +973,7 @@ function renderFunctionComponent(request, task, key, Component, props) {
983
973
  thenableIndexCounter = 0;
984
974
  thenableState = prevThenableState;
985
975
  Component = Component(props, void 0);
986
- if (1 === request.status) throw AbortSigil;
987
- if (
988
- "object" === typeof Component &&
989
- null !== Component &&
990
- Component.$$typeof !== CLIENT_REFERENCE_TAG$1
991
- ) {
976
+ if ("object" === typeof Component && null !== Component) {
992
977
  if ("function" === typeof Component.then) {
993
978
  props = Component;
994
979
  if ("fulfilled" === props.status) return props.value;
@@ -1081,7 +1066,6 @@ function renderElement(request, task, type, key, ref, props) {
1081
1066
  case REACT_LAZY_TYPE:
1082
1067
  var init = type._init;
1083
1068
  type = init(type._payload);
1084
- if (1 === request.status) throw AbortSigil;
1085
1069
  return renderElement(request, task, type, key, ref, props);
1086
1070
  case REACT_FORWARD_REF_TYPE:
1087
1071
  return renderFunctionComponent(request, task, key, type.render, props);
@@ -1098,7 +1082,7 @@ function pingTask(request, task) {
1098
1082
  pingedTasks.push(task);
1099
1083
  1 === pingedTasks.length &&
1100
1084
  ((request.flushScheduled = null !== request.destination),
1101
- scheduleMicrotask(function () {
1085
+ setImmediate(function () {
1102
1086
  return performWork(request);
1103
1087
  }));
1104
1088
  }
@@ -1132,61 +1116,50 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1132
1116
  );
1133
1117
  } catch (thrownValue) {
1134
1118
  if (
1135
- ((parentPropertyName = task.model),
1136
- (parentPropertyName =
1137
- "object" === typeof parentPropertyName &&
1138
- null !== parentPropertyName &&
1139
- (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1140
- parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1141
- (value =
1119
+ ((parentPropertyName =
1142
1120
  thrownValue === SuspenseException
1143
1121
  ? getSuspendedThenable()
1144
1122
  : thrownValue),
1145
- "object" === typeof value &&
1123
+ (value = task.model),
1124
+ (value =
1125
+ "object" === typeof value &&
1146
1126
  null !== value &&
1147
- "function" === typeof value.then)
1148
- )
1149
- if (1 === request.status)
1150
- (task.status = 3),
1151
- (prevKeyPath = request.fatalError),
1152
- (JSCompiler_inline_result = parentPropertyName
1153
- ? "$L" + prevKeyPath.toString(16)
1154
- : serializeByValueID(prevKeyPath));
1155
- else {
1156
- JSCompiler_inline_result = createTask(
1157
- request,
1158
- task.model,
1159
- task.keyPath,
1160
- task.implicitSlot,
1161
- request.abortableTasks
1162
- );
1163
- var ping = JSCompiler_inline_result.ping;
1164
- value.then(ping, ping);
1165
- JSCompiler_inline_result.thenableState =
1166
- getThenableStateAfterSuspending();
1167
- task.keyPath = prevKeyPath;
1168
- task.implicitSlot = prevImplicitSlot;
1169
- JSCompiler_inline_result = parentPropertyName
1170
- ? "$L" + JSCompiler_inline_result.id.toString(16)
1171
- : serializeByValueID(JSCompiler_inline_result.id);
1172
- }
1173
- else if (thrownValue === AbortSigil)
1174
- (task.status = 3),
1175
- (prevKeyPath = request.fatalError),
1176
- (JSCompiler_inline_result = parentPropertyName
1177
- ? "$L" + prevKeyPath.toString(16)
1178
- : serializeByValueID(prevKeyPath));
1179
- else if (
1127
+ (value.$$typeof === REACT_ELEMENT_TYPE ||
1128
+ value.$$typeof === REACT_LAZY_TYPE)),
1129
+ "object" === typeof parentPropertyName &&
1130
+ null !== parentPropertyName &&
1131
+ "function" === typeof parentPropertyName.then)
1132
+ ) {
1133
+ JSCompiler_inline_result = createTask(
1134
+ request,
1135
+ task.model,
1136
+ task.keyPath,
1137
+ task.implicitSlot,
1138
+ request.abortableTasks
1139
+ );
1140
+ var ping = JSCompiler_inline_result.ping;
1141
+ parentPropertyName.then(ping, ping);
1142
+ JSCompiler_inline_result.thenableState =
1143
+ getThenableStateAfterSuspending();
1144
+ task.keyPath = prevKeyPath;
1145
+ task.implicitSlot = prevImplicitSlot;
1146
+ JSCompiler_inline_result = value
1147
+ ? "$L" + JSCompiler_inline_result.id.toString(16)
1148
+ : serializeByValueID(JSCompiler_inline_result.id);
1149
+ } else if (
1180
1150
  ((task.keyPath = prevKeyPath),
1181
1151
  (task.implicitSlot = prevImplicitSlot),
1182
- parentPropertyName)
1152
+ value)
1183
1153
  )
1184
1154
  request.pendingChunks++,
1185
1155
  (prevKeyPath = request.nextChunkId++),
1186
- (prevImplicitSlot = logRecoverableError(request, value)),
1156
+ (prevImplicitSlot = logRecoverableError(
1157
+ request,
1158
+ parentPropertyName
1159
+ )),
1187
1160
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1188
1161
  (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1189
- else throw value;
1162
+ else throw parentPropertyName;
1190
1163
  }
1191
1164
  return JSCompiler_inline_result;
1192
1165
  },
@@ -1337,11 +1310,12 @@ function renderModelDestructive(
1337
1310
  parentPropertyName
1338
1311
  );
1339
1312
  case REACT_LAZY_TYPE:
1340
- task.thenableState = null;
1341
- parentPropertyName = value._init;
1342
- value = parentPropertyName(value._payload);
1343
- if (1 === request.status) throw AbortSigil;
1344
- return renderModelDestructive(request, task, emptyRoot, "", value);
1313
+ return (
1314
+ (task.thenableState = null),
1315
+ (parentPropertyName = value._init),
1316
+ (value = parentPropertyName(value._payload)),
1317
+ renderModelDestructive(request, task, emptyRoot, "", value)
1318
+ );
1345
1319
  case REACT_LEGACY_ELEMENT_TYPE:
1346
1320
  throw Error(
1347
1321
  '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.'
@@ -1601,18 +1575,14 @@ function logRecoverableError(request, error) {
1601
1575
  }
1602
1576
  function fatalError(request, error) {
1603
1577
  null !== request.destination
1604
- ? ((request.status = 3), request.destination.destroy(error))
1605
- : ((request.status = 2), (request.fatalError = error));
1578
+ ? ((request.status = 2), request.destination.destroy(error))
1579
+ : ((request.status = 1), (request.fatalError = error));
1606
1580
  }
1607
1581
  function emitErrorChunk(request, id, digest) {
1608
1582
  digest = { digest: digest };
1609
1583
  id = id.toString(16) + ":E" + stringify(digest) + "\n";
1610
1584
  request.completedErrorChunks.push(id);
1611
1585
  }
1612
- function emitModelChunk(request, id, json) {
1613
- id = id.toString(16) + ":" + json + "\n";
1614
- request.completedRegularChunks.push(id);
1615
- }
1616
1586
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1617
1587
  request.pendingChunks++;
1618
1588
  typedArray = new Uint8Array(
@@ -1664,12 +1634,12 @@ function emitChunk(request, task, value) {
1664
1634
  : value instanceof DataView
1665
1635
  ? emitTypedArrayChunk(request, id, "V", value)
1666
1636
  : ((value = stringify(value, task.toJSON)),
1667
- emitModelChunk(request, task.id, value));
1637
+ (task = task.id.toString(16) + ":" + value + "\n"),
1638
+ request.completedRegularChunks.push(task));
1668
1639
  }
1669
1640
  var emptyRoot = {};
1670
1641
  function retryTask(request, task) {
1671
- if (0 === task.status) {
1672
- task.status = 5;
1642
+ if (0 === task.status)
1673
1643
  try {
1674
1644
  modelRoot = task.model;
1675
1645
  var resolvedModel = renderModelDestructive(
@@ -1686,8 +1656,9 @@ function retryTask(request, task) {
1686
1656
  request.writtenObjects.set(resolvedModel, serializeByValueID(task.id)),
1687
1657
  emitChunk(request, task, resolvedModel);
1688
1658
  else {
1689
- var json = stringify(resolvedModel);
1690
- emitModelChunk(request, task.id, json);
1659
+ var json = stringify(resolvedModel),
1660
+ processedChunk = task.id.toString(16) + ":" + json + "\n";
1661
+ request.completedRegularChunks.push(processedChunk);
1691
1662
  }
1692
1663
  request.abortableTasks.delete(task);
1693
1664
  task.status = 1;
@@ -1696,23 +1667,10 @@ function retryTask(request, task) {
1696
1667
  thrownValue === SuspenseException
1697
1668
  ? getSuspendedThenable()
1698
1669
  : thrownValue;
1699
- if ("object" === typeof x && null !== x && "function" === typeof x.then)
1700
- if (1 === request.status) {
1701
- request.abortableTasks.delete(task);
1702
- task.status = 3;
1703
- var model = stringify(serializeByValueID(request.fatalError));
1704
- emitModelChunk(request, task.id, model);
1705
- } else {
1706
- task.status = 0;
1707
- task.thenableState = getThenableStateAfterSuspending();
1708
- var ping = task.ping;
1709
- x.then(ping, ping);
1710
- }
1711
- else if (x === AbortSigil) {
1712
- request.abortableTasks.delete(task);
1713
- task.status = 3;
1714
- var model$19 = stringify(serializeByValueID(request.fatalError));
1715
- emitModelChunk(request, task.id, model$19);
1670
+ if ("object" === typeof x && null !== x && "function" === typeof x.then) {
1671
+ var ping = task.ping;
1672
+ x.then(ping, ping);
1673
+ task.thenableState = getThenableStateAfterSuspending();
1716
1674
  } else {
1717
1675
  request.abortableTasks.delete(task);
1718
1676
  task.status = 4;
@@ -1721,7 +1679,6 @@ function retryTask(request, task) {
1721
1679
  }
1722
1680
  } finally {
1723
1681
  }
1724
- }
1725
1682
  }
1726
1683
  function performWork(request) {
1727
1684
  var prevDispatcher = ReactSharedInternalsServer.H;
@@ -1803,7 +1760,7 @@ function flushCompletedChunks(request, destination) {
1803
1760
  }
1804
1761
  "function" === typeof destination.flush && destination.flush();
1805
1762
  0 === request.pendingChunks &&
1806
- ((request.status = 3), destination.end(), (request.destination = null));
1763
+ (destination.end(), (request.destination = null));
1807
1764
  }
1808
1765
  function startWork(request) {
1809
1766
  request.flushScheduled = null !== request.destination;
@@ -1812,20 +1769,22 @@ function startWork(request) {
1812
1769
  });
1813
1770
  }
1814
1771
  function enqueueFlush(request) {
1815
- !1 === request.flushScheduled &&
1772
+ if (
1773
+ !1 === request.flushScheduled &&
1816
1774
  0 === request.pingedTasks.length &&
1817
- null !== request.destination &&
1818
- ((request.flushScheduled = !0),
1775
+ null !== request.destination
1776
+ ) {
1777
+ var destination = request.destination;
1778
+ request.flushScheduled = !0;
1819
1779
  setImmediate(function () {
1820
- request.flushScheduled = !1;
1821
- var destination = request.destination;
1822
- destination && flushCompletedChunks(request, destination);
1823
- }));
1780
+ return flushCompletedChunks(request, destination);
1781
+ });
1782
+ }
1824
1783
  }
1825
1784
  function startFlowing(request, destination) {
1826
- if (2 === request.status)
1827
- (request.status = 3), destination.destroy(request.fatalError);
1828
- else if (3 !== request.status && null === request.destination) {
1785
+ if (1 === request.status)
1786
+ (request.status = 2), destination.destroy(request.fatalError);
1787
+ else if (2 !== request.status && null === request.destination) {
1829
1788
  request.destination = destination;
1830
1789
  try {
1831
1790
  flushCompletedChunks(request, destination);
@@ -1836,51 +1795,39 @@ function startFlowing(request, destination) {
1836
1795
  }
1837
1796
  function abort(request, reason) {
1838
1797
  try {
1839
- request.status = 1;
1840
1798
  var abortableTasks = request.abortableTasks;
1841
1799
  if (0 < abortableTasks.size) {
1842
1800
  request.pendingChunks++;
1843
- var errorId = request.nextChunkId++;
1844
- request.fatalError = errorId;
1845
- var error =
1801
+ var errorId = request.nextChunkId++,
1802
+ error =
1846
1803
  void 0 === reason
1847
1804
  ? Error("The render was aborted by the server without a reason.")
1848
- : "object" === typeof reason &&
1849
- null !== reason &&
1850
- "function" === typeof reason.then
1851
- ? Error("The render was aborted by the server with a promise.")
1852
1805
  : reason,
1853
1806
  digest = logRecoverableError(request, error);
1854
1807
  emitErrorChunk(request, errorId, digest, error);
1855
1808
  abortableTasks.forEach(function (task) {
1856
- if (5 !== task.status) {
1857
- task.status = 3;
1858
- var ref = serializeByValueID(errorId);
1859
- task = encodeReferenceChunk(request, task.id, ref);
1860
- request.completedErrorChunks.push(task);
1861
- }
1809
+ task.status = 3;
1810
+ var ref = serializeByValueID(errorId);
1811
+ task = encodeReferenceChunk(request, task.id, ref);
1812
+ request.completedErrorChunks.push(task);
1862
1813
  });
1863
1814
  abortableTasks.clear();
1864
1815
  }
1865
1816
  var abortListeners = request.abortListeners;
1866
1817
  if (0 < abortListeners.size) {
1867
- var error$26 =
1818
+ var error$22 =
1868
1819
  void 0 === reason
1869
1820
  ? Error("The render was aborted by the server without a reason.")
1870
- : "object" === typeof reason &&
1871
- null !== reason &&
1872
- "function" === typeof reason.then
1873
- ? Error("The render was aborted by the server with a promise.")
1874
1821
  : reason;
1875
1822
  abortListeners.forEach(function (callback) {
1876
- return callback(error$26);
1823
+ return callback(error$22);
1877
1824
  });
1878
1825
  abortListeners.clear();
1879
1826
  }
1880
1827
  null !== request.destination &&
1881
1828
  flushCompletedChunks(request, request.destination);
1882
- } catch (error$27) {
1883
- logRecoverableError(request, error$27), fatalError(request, error$27);
1829
+ } catch (error$23) {
1830
+ logRecoverableError(request, error$23), fatalError(request, error$23);
1884
1831
  }
1885
1832
  }
1886
1833
  function resolveServerReference(bundlerConfig, id) {
@@ -2323,8 +2270,8 @@ function parseReadableStream(response, reference, type) {
2323
2270
  (previousBlockedChunk = chunk));
2324
2271
  } else {
2325
2272
  chunk = previousBlockedChunk;
2326
- var chunk$30 = createPendingChunk(response);
2327
- chunk$30.then(
2273
+ var chunk$26 = createPendingChunk(response);
2274
+ chunk$26.then(
2328
2275
  function (v) {
2329
2276
  return controller.enqueue(v);
2330
2277
  },
@@ -2332,10 +2279,10 @@ function parseReadableStream(response, reference, type) {
2332
2279
  return controller.error(e);
2333
2280
  }
2334
2281
  );
2335
- previousBlockedChunk = chunk$30;
2282
+ previousBlockedChunk = chunk$26;
2336
2283
  chunk.then(function () {
2337
- previousBlockedChunk === chunk$30 && (previousBlockedChunk = null);
2338
- resolveModelChunk(chunk$30, json, -1);
2284
+ previousBlockedChunk === chunk$26 && (previousBlockedChunk = null);
2285
+ resolveModelChunk(chunk$26, json, -1);
2339
2286
  });
2340
2287
  }
2341
2288
  },
@@ -2693,12 +2640,12 @@ exports.decodeReplyFromBusboy = function (busboyStream, webpackMap, options) {
2693
2640
  "React doesn't accept base64 encoded file uploads because we don't expect form data passed from a browser to ever encode data that way. If that's the wrong assumption, we can easily fix it."
2694
2641
  );
2695
2642
  pendingFiles++;
2696
- var JSCompiler_object_inline_chunks_201 = [];
2643
+ var JSCompiler_object_inline_chunks_216 = [];
2697
2644
  value.on("data", function (chunk) {
2698
- JSCompiler_object_inline_chunks_201.push(chunk);
2645
+ JSCompiler_object_inline_chunks_216.push(chunk);
2699
2646
  });
2700
2647
  value.on("end", function () {
2701
- var blob = new Blob(JSCompiler_object_inline_chunks_201, {
2648
+ var blob = new Blob(JSCompiler_object_inline_chunks_216, {
2702
2649
  type: mimeType
2703
2650
  });
2704
2651
  response._formData.append(name, blob, filename);