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.
@@ -11,30 +11,6 @@
11
11
  "use strict";
12
12
  var ReactDOM = require("react-dom"),
13
13
  React = require("react"),
14
- channel = new MessageChannel(),
15
- taskQueue = [];
16
- channel.port1.onmessage = function () {
17
- var task = taskQueue.shift();
18
- task && task();
19
- };
20
- function scheduleWork(callback) {
21
- taskQueue.push(callback);
22
- channel.port2.postMessage(null);
23
- }
24
- function handleErrorInNextTick(error) {
25
- setTimeout(function () {
26
- throw error;
27
- });
28
- }
29
- var LocalPromise = Promise,
30
- scheduleMicrotask =
31
- "function" === typeof queueMicrotask
32
- ? queueMicrotask
33
- : function (callback) {
34
- LocalPromise.resolve(null)
35
- .then(callback)
36
- .catch(handleErrorInNextTick);
37
- },
38
14
  currentView = null,
39
15
  writtenBytes = 0;
40
16
  function writeChunkAndReturn(destination, chunk) {
@@ -694,8 +670,7 @@ if (!ReactSharedInternalsServer)
694
670
  '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.'
695
671
  );
696
672
  var ObjectPrototype = Object.prototype,
697
- stringify = JSON.stringify,
698
- AbortSigil = {};
673
+ stringify = JSON.stringify;
699
674
  function defaultErrorHandler(error) {
700
675
  console.error(error);
701
676
  }
@@ -771,14 +746,6 @@ function serializeThenable(request, task, thenable) {
771
746
  newTask.id
772
747
  );
773
748
  default:
774
- if (1 === request.status)
775
- return (
776
- (newTask.status = 3),
777
- (task = stringify(serializeByValueID(request.fatalError))),
778
- emitModelChunk(request, newTask.id, task),
779
- request.abortableTasks.delete(newTask),
780
- newTask.id
781
- );
782
749
  "string" !== typeof thenable.status &&
783
750
  ((thenable.status = "pending"),
784
751
  thenable.then(
@@ -965,12 +932,7 @@ function renderFunctionComponent(request, task, key, Component, props) {
965
932
  thenableIndexCounter = 0;
966
933
  thenableState = prevThenableState;
967
934
  Component = Component(props, void 0);
968
- if (1 === request.status) throw AbortSigil;
969
- if (
970
- "object" === typeof Component &&
971
- null !== Component &&
972
- Component.$$typeof !== CLIENT_REFERENCE_TAG$1
973
- ) {
935
+ if ("object" === typeof Component && null !== Component) {
974
936
  if ("function" === typeof Component.then) {
975
937
  props = Component;
976
938
  if ("fulfilled" === props.status) return props.value;
@@ -1063,7 +1025,6 @@ function renderElement(request, task, type, key, ref, props) {
1063
1025
  case REACT_LAZY_TYPE:
1064
1026
  var init = type._init;
1065
1027
  type = init(type._payload);
1066
- if (1 === request.status) throw AbortSigil;
1067
1028
  return renderElement(request, task, type, key, ref, props);
1068
1029
  case REACT_FORWARD_REF_TYPE:
1069
1030
  return renderFunctionComponent(request, task, key, type.render, props);
@@ -1080,9 +1041,7 @@ function pingTask(request, task) {
1080
1041
  pingedTasks.push(task);
1081
1042
  1 === pingedTasks.length &&
1082
1043
  ((request.flushScheduled = null !== request.destination),
1083
- scheduleMicrotask(function () {
1084
- return performWork(request);
1085
- }));
1044
+ performWork(request));
1086
1045
  }
1087
1046
  function createTask(request, model, keyPath, implicitSlot, abortSet) {
1088
1047
  request.pendingChunks++;
@@ -1114,61 +1073,50 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1114
1073
  );
1115
1074
  } catch (thrownValue) {
1116
1075
  if (
1117
- ((parentPropertyName = task.model),
1118
- (parentPropertyName =
1119
- "object" === typeof parentPropertyName &&
1120
- null !== parentPropertyName &&
1121
- (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1122
- parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1123
- (value =
1076
+ ((parentPropertyName =
1124
1077
  thrownValue === SuspenseException
1125
1078
  ? getSuspendedThenable()
1126
1079
  : thrownValue),
1127
- "object" === typeof value &&
1080
+ (value = task.model),
1081
+ (value =
1082
+ "object" === typeof value &&
1128
1083
  null !== value &&
1129
- "function" === typeof value.then)
1130
- )
1131
- if (1 === request.status)
1132
- (task.status = 3),
1133
- (prevKeyPath = request.fatalError),
1134
- (JSCompiler_inline_result = parentPropertyName
1135
- ? "$L" + prevKeyPath.toString(16)
1136
- : serializeByValueID(prevKeyPath));
1137
- else {
1138
- JSCompiler_inline_result = createTask(
1139
- request,
1140
- task.model,
1141
- task.keyPath,
1142
- task.implicitSlot,
1143
- request.abortableTasks
1144
- );
1145
- var ping = JSCompiler_inline_result.ping;
1146
- value.then(ping, ping);
1147
- JSCompiler_inline_result.thenableState =
1148
- getThenableStateAfterSuspending();
1149
- task.keyPath = prevKeyPath;
1150
- task.implicitSlot = prevImplicitSlot;
1151
- JSCompiler_inline_result = parentPropertyName
1152
- ? "$L" + JSCompiler_inline_result.id.toString(16)
1153
- : serializeByValueID(JSCompiler_inline_result.id);
1154
- }
1155
- else if (thrownValue === AbortSigil)
1156
- (task.status = 3),
1157
- (prevKeyPath = request.fatalError),
1158
- (JSCompiler_inline_result = parentPropertyName
1159
- ? "$L" + prevKeyPath.toString(16)
1160
- : serializeByValueID(prevKeyPath));
1161
- else if (
1084
+ (value.$$typeof === REACT_ELEMENT_TYPE ||
1085
+ value.$$typeof === REACT_LAZY_TYPE)),
1086
+ "object" === typeof parentPropertyName &&
1087
+ null !== parentPropertyName &&
1088
+ "function" === typeof parentPropertyName.then)
1089
+ ) {
1090
+ JSCompiler_inline_result = createTask(
1091
+ request,
1092
+ task.model,
1093
+ task.keyPath,
1094
+ task.implicitSlot,
1095
+ request.abortableTasks
1096
+ );
1097
+ var ping = JSCompiler_inline_result.ping;
1098
+ parentPropertyName.then(ping, ping);
1099
+ JSCompiler_inline_result.thenableState =
1100
+ getThenableStateAfterSuspending();
1101
+ task.keyPath = prevKeyPath;
1102
+ task.implicitSlot = prevImplicitSlot;
1103
+ JSCompiler_inline_result = value
1104
+ ? "$L" + JSCompiler_inline_result.id.toString(16)
1105
+ : serializeByValueID(JSCompiler_inline_result.id);
1106
+ } else if (
1162
1107
  ((task.keyPath = prevKeyPath),
1163
1108
  (task.implicitSlot = prevImplicitSlot),
1164
- parentPropertyName)
1109
+ value)
1165
1110
  )
1166
1111
  request.pendingChunks++,
1167
1112
  (prevKeyPath = request.nextChunkId++),
1168
- (prevImplicitSlot = logRecoverableError(request, value)),
1113
+ (prevImplicitSlot = logRecoverableError(
1114
+ request,
1115
+ parentPropertyName
1116
+ )),
1169
1117
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1170
1118
  (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1171
- else throw value;
1119
+ else throw parentPropertyName;
1172
1120
  }
1173
1121
  return JSCompiler_inline_result;
1174
1122
  },
@@ -1321,11 +1269,12 @@ function renderModelDestructive(
1321
1269
  parentPropertyName
1322
1270
  );
1323
1271
  case REACT_LAZY_TYPE:
1324
- task.thenableState = null;
1325
- parentPropertyName = value._init;
1326
- value = parentPropertyName(value._payload);
1327
- if (1 === request.status) throw AbortSigil;
1328
- return renderModelDestructive(request, task, emptyRoot, "", value);
1272
+ return (
1273
+ (task.thenableState = null),
1274
+ (parentPropertyName = value._init),
1275
+ (value = parentPropertyName(value._payload)),
1276
+ renderModelDestructive(request, task, emptyRoot, "", value)
1277
+ );
1329
1278
  case REACT_LEGACY_ELEMENT_TYPE:
1330
1279
  throw Error(
1331
1280
  '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.'
@@ -1586,8 +1535,8 @@ function logRecoverableError(request, error) {
1586
1535
  }
1587
1536
  function fatalError(request, error) {
1588
1537
  null !== request.destination
1589
- ? ((request.status = 3), closeWithError(request.destination, error))
1590
- : ((request.status = 2), (request.fatalError = error));
1538
+ ? ((request.status = 2), closeWithError(request.destination, error))
1539
+ : ((request.status = 1), (request.fatalError = error));
1591
1540
  }
1592
1541
  function emitErrorChunk(request, id, digest) {
1593
1542
  digest = { digest: digest };
@@ -1656,8 +1605,7 @@ function emitChunk(request, task, value) {
1656
1605
  }
1657
1606
  var emptyRoot = {};
1658
1607
  function retryTask(request, task) {
1659
- if (0 === task.status) {
1660
- task.status = 5;
1608
+ if (0 === task.status)
1661
1609
  try {
1662
1610
  modelRoot = task.model;
1663
1611
  var resolvedModel = renderModelDestructive(
@@ -1684,23 +1632,10 @@ function retryTask(request, task) {
1684
1632
  thrownValue === SuspenseException
1685
1633
  ? getSuspendedThenable()
1686
1634
  : thrownValue;
1687
- if ("object" === typeof x && null !== x && "function" === typeof x.then)
1688
- if (1 === request.status) {
1689
- request.abortableTasks.delete(task);
1690
- task.status = 3;
1691
- var model = stringify(serializeByValueID(request.fatalError));
1692
- emitModelChunk(request, task.id, model);
1693
- } else {
1694
- task.status = 0;
1695
- task.thenableState = getThenableStateAfterSuspending();
1696
- var ping = task.ping;
1697
- x.then(ping, ping);
1698
- }
1699
- else if (x === AbortSigil) {
1700
- request.abortableTasks.delete(task);
1701
- task.status = 3;
1702
- var model$19 = stringify(serializeByValueID(request.fatalError));
1703
- emitModelChunk(request, task.id, model$19);
1635
+ if ("object" === typeof x && null !== x && "function" === typeof x.then) {
1636
+ var ping = task.ping;
1637
+ x.then(ping, ping);
1638
+ task.thenableState = getThenableStateAfterSuspending();
1704
1639
  } else {
1705
1640
  request.abortableTasks.delete(task);
1706
1641
  task.status = 4;
@@ -1709,7 +1644,6 @@ function retryTask(request, task) {
1709
1644
  }
1710
1645
  } finally {
1711
1646
  }
1712
- }
1713
1647
  }
1714
1648
  function performWork(request) {
1715
1649
  var prevDispatcher = ReactSharedInternalsServer.H;
@@ -1767,72 +1701,54 @@ function flushCompletedChunks(request, destination) {
1767
1701
  (writtenBytes = 0));
1768
1702
  }
1769
1703
  0 === request.pendingChunks &&
1770
- ((request.status = 3), destination.close(), (request.destination = null));
1771
- }
1772
- function startWork(request) {
1773
- request.flushScheduled = null !== request.destination;
1774
- scheduleWork(function () {
1775
- return performWork(request);
1776
- });
1704
+ (destination.close(), (request.destination = null));
1777
1705
  }
1778
1706
  function enqueueFlush(request) {
1779
- !1 === request.flushScheduled &&
1707
+ if (
1708
+ !1 === request.flushScheduled &&
1780
1709
  0 === request.pingedTasks.length &&
1781
- null !== request.destination &&
1782
- ((request.flushScheduled = !0),
1783
- scheduleWork(function () {
1784
- request.flushScheduled = !1;
1785
- var destination = request.destination;
1786
- destination && flushCompletedChunks(request, destination);
1787
- }));
1710
+ null !== request.destination
1711
+ ) {
1712
+ var destination = request.destination;
1713
+ request.flushScheduled = !0;
1714
+ flushCompletedChunks(request, destination);
1715
+ }
1788
1716
  }
1789
1717
  function abort(request, reason) {
1790
1718
  try {
1791
- request.status = 1;
1792
1719
  var abortableTasks = request.abortableTasks;
1793
1720
  if (0 < abortableTasks.size) {
1794
1721
  request.pendingChunks++;
1795
- var errorId = request.nextChunkId++;
1796
- request.fatalError = errorId;
1797
- var error =
1722
+ var errorId = request.nextChunkId++,
1723
+ error =
1798
1724
  void 0 === reason
1799
1725
  ? Error("The render was aborted by the server without a reason.")
1800
- : "object" === typeof reason &&
1801
- null !== reason &&
1802
- "function" === typeof reason.then
1803
- ? Error("The render was aborted by the server with a promise.")
1804
1726
  : reason,
1805
1727
  digest = logRecoverableError(request, error);
1806
1728
  emitErrorChunk(request, errorId, digest, error);
1807
1729
  abortableTasks.forEach(function (task) {
1808
- if (5 !== task.status) {
1809
- task.status = 3;
1810
- var ref = serializeByValueID(errorId);
1811
- task = encodeReferenceChunk(request, task.id, ref);
1812
- request.completedErrorChunks.push(task);
1813
- }
1730
+ task.status = 3;
1731
+ var ref = serializeByValueID(errorId);
1732
+ task = encodeReferenceChunk(request, task.id, ref);
1733
+ request.completedErrorChunks.push(task);
1814
1734
  });
1815
1735
  abortableTasks.clear();
1816
1736
  }
1817
1737
  var abortListeners = request.abortListeners;
1818
1738
  if (0 < abortListeners.size) {
1819
- var error$26 =
1739
+ var error$22 =
1820
1740
  void 0 === reason
1821
1741
  ? Error("The render was aborted by the server without a reason.")
1822
- : "object" === typeof reason &&
1823
- null !== reason &&
1824
- "function" === typeof reason.then
1825
- ? Error("The render was aborted by the server with a promise.")
1826
1742
  : reason;
1827
1743
  abortListeners.forEach(function (callback) {
1828
- return callback(error$26);
1744
+ return callback(error$22);
1829
1745
  });
1830
1746
  abortListeners.clear();
1831
1747
  }
1832
1748
  null !== request.destination &&
1833
1749
  flushCompletedChunks(request, request.destination);
1834
- } catch (error$27) {
1835
- logRecoverableError(request, error$27), fatalError(request, error$27);
1750
+ } catch (error$23) {
1751
+ logRecoverableError(request, error$23), fatalError(request, error$23);
1836
1752
  }
1837
1753
  }
1838
1754
  function resolveServerReference(bundlerConfig, id) {
@@ -2284,8 +2200,8 @@ function parseReadableStream(response, reference, type) {
2284
2200
  (previousBlockedChunk = chunk));
2285
2201
  } else {
2286
2202
  chunk = previousBlockedChunk;
2287
- var chunk$30 = createPendingChunk(response);
2288
- chunk$30.then(
2203
+ var chunk$26 = createPendingChunk(response);
2204
+ chunk$26.then(
2289
2205
  function (v) {
2290
2206
  return controller.enqueue(v);
2291
2207
  },
@@ -2293,10 +2209,10 @@ function parseReadableStream(response, reference, type) {
2293
2209
  return controller.error(e);
2294
2210
  }
2295
2211
  );
2296
- previousBlockedChunk = chunk$30;
2212
+ previousBlockedChunk = chunk$26;
2297
2213
  chunk.then(function () {
2298
- previousBlockedChunk === chunk$30 && (previousBlockedChunk = null);
2299
- resolveModelChunk(chunk$30, json, -1);
2214
+ previousBlockedChunk === chunk$26 && (previousBlockedChunk = null);
2215
+ resolveModelChunk(chunk$26, json, -1);
2300
2216
  });
2301
2217
  }
2302
2218
  },
@@ -2661,12 +2577,13 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
2661
2577
  {
2662
2578
  type: "bytes",
2663
2579
  start: function () {
2664
- startWork(request);
2580
+ request.flushScheduled = null !== request.destination;
2581
+ performWork(request);
2665
2582
  },
2666
2583
  pull: function (controller) {
2667
- if (2 === request.status)
2668
- (request.status = 3), closeWithError(controller, request.fatalError);
2669
- else if (3 !== request.status && null === request.destination) {
2584
+ if (1 === request.status)
2585
+ (request.status = 2), closeWithError(controller, request.fatalError);
2586
+ else if (2 !== request.status && null === request.destination) {
2670
2587
  request.destination = controller;
2671
2588
  try {
2672
2589
  flushCompletedChunks(request, controller);