react-server-dom-webpack 19.0.0-rc-e56f4ae3-20240830 → 19.0.0-rc-4f604941-20240830

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.
@@ -347,6 +347,11 @@
347
347
  function unsupportedContext() {
348
348
  throw Error("Cannot read a Client Context from a Server Component.");
349
349
  }
350
+ function resolveOwner() {
351
+ if (currentOwner) return currentOwner;
352
+ var owner = componentStorage.getStore();
353
+ return owner ? owner : null;
354
+ }
350
355
  function isObjectPrototype(object) {
351
356
  if (!object) return !1;
352
357
  var ObjectPrototype = Object.prototype;
@@ -544,6 +549,55 @@
544
549
  !filename.includes("node_modules")
545
550
  );
546
551
  }
552
+ function filterStackTrace(request, error, skipFrames) {
553
+ request = request.filterStackFrame;
554
+ error = parseStackTrace(error, skipFrames);
555
+ for (skipFrames = 0; skipFrames < error.length; skipFrames++) {
556
+ var callsite = error[skipFrames],
557
+ functionName = callsite[0],
558
+ url = callsite[1];
559
+ if (url.startsWith("rsc://React/")) {
560
+ var envIdx = url.indexOf("/", 12),
561
+ suffixIdx = url.lastIndexOf("?");
562
+ -1 < envIdx &&
563
+ -1 < suffixIdx &&
564
+ (url = callsite[1] = url.slice(envIdx + 1, suffixIdx));
565
+ }
566
+ request(url, functionName) ||
567
+ (error.splice(skipFrames, 1), skipFrames--);
568
+ }
569
+ return error;
570
+ }
571
+ function patchConsole(consoleInst, methodName) {
572
+ var descriptor = Object.getOwnPropertyDescriptor(consoleInst, methodName);
573
+ if (
574
+ descriptor &&
575
+ (descriptor.configurable || descriptor.writable) &&
576
+ "function" === typeof descriptor.value
577
+ ) {
578
+ var originalMethod = descriptor.value;
579
+ descriptor = Object.getOwnPropertyDescriptor(originalMethod, "name");
580
+ var wrapperMethod = function () {
581
+ var request = resolveRequest();
582
+ if (("assert" !== methodName || !arguments[0]) && null !== request) {
583
+ var stack = filterStackTrace(
584
+ request,
585
+ Error("react-stack-top-frame"),
586
+ 1
587
+ );
588
+ request.pendingChunks++;
589
+ var id = request.nextChunkId++,
590
+ owner = resolveOwner();
591
+ emitConsoleChunk(request, id, methodName, owner, stack, arguments);
592
+ }
593
+ return originalMethod.apply(this, arguments);
594
+ };
595
+ descriptor && Object.defineProperty(wrapperMethod, "name", descriptor);
596
+ Object.defineProperty(consoleInst, methodName, {
597
+ value: wrapperMethod
598
+ });
599
+ }
600
+ }
547
601
  function getCurrentStackInDEV() {
548
602
  return "";
549
603
  }
@@ -650,14 +704,14 @@
650
704
  task = thenable.reason;
651
705
  var digest = logRecoverableError(request, task, null);
652
706
  emitErrorChunk(request, newTask.id, digest, task);
653
- newTask.status = 4;
707
+ newTask.status = ERRORED$1;
654
708
  request.abortableTasks.delete(newTask);
655
709
  return newTask.id;
656
710
  default:
657
- if (11 === request.status)
711
+ if (request.status === ABORTING)
658
712
  return (
659
713
  request.abortableTasks.delete(newTask),
660
- (newTask.status = 3),
714
+ (newTask.status = ABORTED),
661
715
  (task = stringify(serializeByValueID(request.fatalError))),
662
716
  emitModelChunk(request, newTask.id, task),
663
717
  newTask.id
@@ -684,7 +738,7 @@
684
738
  function (reason) {
685
739
  var _digest = logRecoverableError(request, reason, newTask);
686
740
  emitErrorChunk(request, newTask.id, _digest, reason);
687
- newTask.status = 4;
741
+ newTask.status = ERRORED$1;
688
742
  request.abortableTasks.delete(newTask);
689
743
  enqueueFlush(request);
690
744
  }
@@ -835,9 +889,8 @@
835
889
  function emitHint(request, code, model) {
836
890
  model = stringify(model);
837
891
  var id = request.nextChunkId++;
838
- code = "H" + code;
839
- code = id.toString(16) + ":" + code;
840
- request.completedHintChunks.push(code + model + "\n");
892
+ code = serializeRowHeader("H" + code, id) + model + "\n";
893
+ request.completedHintChunks.push(code);
841
894
  enqueueFlush(request);
842
895
  }
843
896
  function readThenable(thenable) {
@@ -915,7 +968,7 @@
915
968
  props,
916
969
  componentDebugInfo
917
970
  );
918
- if (11 === request.status)
971
+ if (request.status === ABORTING)
919
972
  throw (
920
973
  ("object" !== typeof props ||
921
974
  null === props ||
@@ -1048,7 +1101,7 @@
1048
1101
  task.debugOwner
1049
1102
  );
1050
1103
  retryTask(request, task);
1051
- return 1 === task.status
1104
+ return task.status === COMPLETED
1052
1105
  ? serializeByValueID(task.id)
1053
1106
  : "$L" + task.id.toString(16);
1054
1107
  }
@@ -1088,7 +1141,7 @@
1088
1141
  switch (type.$$typeof) {
1089
1142
  case REACT_LAZY_TYPE:
1090
1143
  type = callLazyInitInDEV(type);
1091
- if (11 === request.status) throw null;
1144
+ if (request.status === ABORTING) throw null;
1092
1145
  return renderElement(request, task, type, key, ref, props);
1093
1146
  case REACT_FORWARD_REF_TYPE:
1094
1147
  return renderFunctionComponent(
@@ -1118,7 +1171,7 @@
1118
1171
  pingedTasks.push(task);
1119
1172
  1 === pingedTasks.length &&
1120
1173
  ((request.flushScheduled = null !== request.destination),
1121
- 21 === request.type
1174
+ request.type === PRERENDER
1122
1175
  ? scheduleMicrotask(function () {
1123
1176
  return performWork(request);
1124
1177
  })
@@ -1143,7 +1196,7 @@
1143
1196
  request.writtenObjects.set(model, serializeByValueID(id));
1144
1197
  var task = {
1145
1198
  id: id,
1146
- status: 0,
1199
+ status: PENDING$1,
1147
1200
  model: model,
1148
1201
  keyPath: keyPath,
1149
1202
  implicitSlot: implicitSlot,
@@ -1197,6 +1250,9 @@
1197
1250
  ? "$-Infinity"
1198
1251
  : "$NaN";
1199
1252
  }
1253
+ function serializeRowHeader(tag, id) {
1254
+ return id.toString(16) + ":" + tag;
1255
+ }
1200
1256
  function encodeReferenceChunk(request, id, reference) {
1201
1257
  request = stringify(reference);
1202
1258
  return id.toString(16) + ":" + request + "\n";
@@ -1241,7 +1297,7 @@
1241
1297
  request.pendingChunks++;
1242
1298
  var importId = request.nextChunkId++,
1243
1299
  json = stringify(clientReferenceMetadata),
1244
- processedChunk = importId.toString(16) + ":I" + json + "\n";
1300
+ processedChunk = serializeRowHeader("I", importId) + json + "\n";
1245
1301
  request.completedImportChunks.push(processedChunk);
1246
1302
  writtenClientReferences.set(clientReferenceKey, importId);
1247
1303
  return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName
@@ -1393,9 +1449,9 @@
1393
1449
  null !== parent &&
1394
1450
  (parent.$$typeof === REACT_ELEMENT_TYPE ||
1395
1451
  parent.$$typeof === REACT_LAZY_TYPE);
1396
- if (11 === request.status)
1452
+ if (request.status === ABORTING)
1397
1453
  return (
1398
- (task.status = 3),
1454
+ (task.status = ABORTED),
1399
1455
  (task = request.fatalError),
1400
1456
  parent ? "$L" + task.toString(16) : serializeByValueID(task)
1401
1457
  );
@@ -1489,7 +1545,7 @@
1489
1545
  case REACT_LAZY_TYPE:
1490
1546
  task.thenableState = null;
1491
1547
  elementReference = callLazyInitInDEV(value);
1492
- if (11 === request.status) throw null;
1548
+ if (request.status === ABORTING) throw null;
1493
1549
  if ((_writtenObjects = value._debugInfo)) {
1494
1550
  if (null === debugID) return outlineTask(request, task);
1495
1551
  forwardDebugInfo(request, debugID, _writtenObjects);
@@ -1769,33 +1825,14 @@
1769
1825
  onFatalError(error);
1770
1826
  null !== request.destination
1771
1827
  ? ((request.status = CLOSED), request.destination.destroy(error))
1772
- : ((request.status = 12), (request.fatalError = error));
1828
+ : ((request.status = CLOSING), (request.fatalError = error));
1773
1829
  }
1774
1830
  function emitErrorChunk(request, id, digest, error) {
1775
1831
  var env = (0, request.environmentName)();
1776
1832
  try {
1777
1833
  if (error instanceof Error) {
1778
1834
  var message = String(error.message);
1779
- for (
1780
- var filterStackFrame = request.filterStackFrame,
1781
- stack = parseStackTrace(error, 0),
1782
- i = 0;
1783
- i < stack.length;
1784
- i++
1785
- ) {
1786
- var callsite = stack[i],
1787
- functionName = callsite[0],
1788
- url = callsite[1];
1789
- if (url.startsWith("rsc://React/")) {
1790
- var envIdx = url.indexOf("/", 12),
1791
- suffixIdx = url.lastIndexOf("?");
1792
- -1 < envIdx &&
1793
- -1 < suffixIdx &&
1794
- (url = callsite[1] = url.slice(envIdx + 1, suffixIdx));
1795
- }
1796
- filterStackFrame(url, functionName) || (stack.splice(i, 1), i--);
1797
- }
1798
- var stack$jscomp$0 = stack;
1835
+ var stack = filterStackTrace(request, error, 0);
1799
1836
  var errorEnv = error.environmentName;
1800
1837
  "string" === typeof errorEnv && (env = errorEnv);
1801
1838
  } else
@@ -1803,19 +1840,14 @@
1803
1840
  "object" === typeof error && null !== error
1804
1841
  ? describeObjectForErrorMessage(error)
1805
1842
  : String(error)),
1806
- (stack$jscomp$0 = []);
1843
+ (stack = []);
1807
1844
  } catch (x) {
1808
1845
  (message =
1809
1846
  "An error occurred but serializing the error message failed."),
1810
- (stack$jscomp$0 = []);
1847
+ (stack = []);
1811
1848
  }
1812
- digest = {
1813
- digest: digest,
1814
- message: message,
1815
- stack: stack$jscomp$0,
1816
- env: env
1817
- };
1818
- id = id.toString(16) + ":E" + stringify(digest) + "\n";
1849
+ digest = { digest: digest, message: message, stack: stack, env: env };
1850
+ id = serializeRowHeader("E", id) + stringify(digest) + "\n";
1819
1851
  request.completedErrorChunks.push(id);
1820
1852
  }
1821
1853
  function emitSymbolChunk(request, id, name) {
@@ -1837,7 +1869,7 @@
1837
1869
  value
1838
1870
  );
1839
1871
  });
1840
- id = id.toString(16) + ":D" + debugInfo + "\n";
1872
+ id = serializeRowHeader("D", id) + debugInfo + "\n";
1841
1873
  request.completedRegularChunks.push(id);
1842
1874
  }
1843
1875
  function emitTypedArrayChunk(request, id, tag, typedArray) {
@@ -2023,6 +2055,34 @@
2023
2055
  request.completedRegularChunks.push(json);
2024
2056
  return model;
2025
2057
  }
2058
+ function emitConsoleChunk(
2059
+ request,
2060
+ id,
2061
+ methodName,
2062
+ owner,
2063
+ stackTrace,
2064
+ args
2065
+ ) {
2066
+ var counter = { objectCount: 0 },
2067
+ env = (0, request.environmentName)();
2068
+ methodName = [methodName, stackTrace, owner, env];
2069
+ methodName.push.apply(methodName, args);
2070
+ args = stringify(methodName, function (parentPropertyName, value) {
2071
+ try {
2072
+ return renderConsoleValue(
2073
+ request,
2074
+ counter,
2075
+ this,
2076
+ parentPropertyName,
2077
+ value
2078
+ );
2079
+ } catch (x) {
2080
+ return "unknown value";
2081
+ }
2082
+ });
2083
+ id = serializeRowHeader("W", id) + args + "\n";
2084
+ request.completedRegularChunks.push(id);
2085
+ }
2026
2086
  function forwardDebugInfo(request, id, debugInfo) {
2027
2087
  for (var i = 0; i < debugInfo.length; i++)
2028
2088
  request.pendingChunks++,
@@ -2064,9 +2124,9 @@
2064
2124
  emitModelChunk(request, task.id, value));
2065
2125
  }
2066
2126
  function retryTask(request, task) {
2067
- if (0 === task.status) {
2127
+ if (task.status === PENDING$1) {
2068
2128
  var prevDebugID = debugID;
2069
- task.status = 5;
2129
+ task.status = RENDERING;
2070
2130
  try {
2071
2131
  modelRoot = task.model;
2072
2132
  debugID = task.id;
@@ -2098,11 +2158,11 @@
2098
2158
  emitModelChunk(request, task.id, json);
2099
2159
  }
2100
2160
  request.abortableTasks.delete(task);
2101
- task.status = 1;
2161
+ task.status = COMPLETED;
2102
2162
  } catch (thrownValue) {
2103
- if (11 === request.status) {
2163
+ if (request.status === ABORTING) {
2104
2164
  request.abortableTasks.delete(task);
2105
- task.status = 3;
2165
+ task.status = ABORTED;
2106
2166
  var model = stringify(serializeByValueID(request.fatalError));
2107
2167
  emitModelChunk(request, task.id, model);
2108
2168
  } else {
@@ -2115,13 +2175,13 @@
2115
2175
  null !== x &&
2116
2176
  "function" === typeof x.then
2117
2177
  ) {
2118
- task.status = 0;
2178
+ task.status = PENDING$1;
2119
2179
  task.thenableState = getThenableStateAfterSuspending();
2120
2180
  var ping = task.ping;
2121
2181
  x.then(ping, ping);
2122
2182
  } else {
2123
2183
  request.abortableTasks.delete(task);
2124
- task.status = 4;
2184
+ task.status = ERRORED$1;
2125
2185
  var digest = logRecoverableError(request, x, task);
2126
2186
  emitErrorChunk(request, task.id, digest, x);
2127
2187
  }
@@ -2231,7 +2291,7 @@
2231
2291
  }
2232
2292
  function startWork(request) {
2233
2293
  request.flushScheduled = null !== request.destination;
2234
- 21 === request.type
2294
+ request.type === PRERENDER
2235
2295
  ? scheduleMicrotask(function () {
2236
2296
  requestStorage.run(request, performWork, request);
2237
2297
  })
@@ -2251,7 +2311,7 @@
2251
2311
  }));
2252
2312
  }
2253
2313
  function startFlowing(request, destination) {
2254
- if (12 === request.status)
2314
+ if (request.status === CLOSING)
2255
2315
  (request.status = CLOSED), destination.destroy(request.fatalError);
2256
2316
  else if (request.status !== CLOSED && null === request.destination) {
2257
2317
  request.destination = destination;
@@ -2264,7 +2324,7 @@
2264
2324
  }
2265
2325
  function abort(request, reason) {
2266
2326
  try {
2267
- 10 === request.status && (request.status = 11);
2327
+ 10 === request.status && (request.status = ABORTING);
2268
2328
  var abortableTasks = request.abortableTasks;
2269
2329
  if (0 < abortableTasks.size) {
2270
2330
  var error =
@@ -2285,8 +2345,8 @@
2285
2345
  request.pendingChunks++;
2286
2346
  emitErrorChunk(request, _errorId2, digest, error);
2287
2347
  abortableTasks.forEach(function (task) {
2288
- if (5 !== task.status) {
2289
- task.status = 3;
2348
+ if (task.status !== RENDERING) {
2349
+ task.status = ABORTED;
2290
2350
  var ref = serializeByValueID(_errorId2);
2291
2351
  task = encodeReferenceChunk(request, task.id, ref);
2292
2352
  request.completedErrorChunks.push(task);
@@ -3378,15 +3438,11 @@
3378
3438
  void 0 === entry &&
3379
3439
  ((entry = resourceType()), cache.set(resourceType, entry));
3380
3440
  return entry;
3381
- },
3382
- getOwner: function () {
3383
- if (currentOwner) return currentOwner;
3384
- var owner = componentStorage.getStore();
3385
- return owner ? owner : null;
3386
3441
  }
3387
- },
3388
- ReactSharedInternalsServer =
3389
- React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
3442
+ };
3443
+ DefaultAsyncDispatcher.getOwner = resolveOwner;
3444
+ var ReactSharedInternalsServer =
3445
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
3390
3446
  if (!ReactSharedInternalsServer)
3391
3447
  throw Error(
3392
3448
  '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.'
@@ -3427,10 +3483,33 @@
3427
3483
  getPrototypeOf = Object.getPrototypeOf,
3428
3484
  jsxPropsParents = new WeakMap(),
3429
3485
  jsxChildrenParents = new WeakMap(),
3430
- CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"),
3431
- ObjectPrototype = Object.prototype,
3486
+ CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference");
3487
+ "object" === typeof console &&
3488
+ null !== console &&
3489
+ (patchConsole(console, "assert"),
3490
+ patchConsole(console, "debug"),
3491
+ patchConsole(console, "dir"),
3492
+ patchConsole(console, "dirxml"),
3493
+ patchConsole(console, "error"),
3494
+ patchConsole(console, "group"),
3495
+ patchConsole(console, "groupCollapsed"),
3496
+ patchConsole(console, "groupEnd"),
3497
+ patchConsole(console, "info"),
3498
+ patchConsole(console, "log"),
3499
+ patchConsole(console, "table"),
3500
+ patchConsole(console, "trace"),
3501
+ patchConsole(console, "warn"));
3502
+ var ObjectPrototype = Object.prototype,
3432
3503
  stringify = JSON.stringify,
3504
+ PENDING$1 = 0,
3505
+ COMPLETED = 1,
3506
+ ABORTED = 3,
3507
+ ERRORED$1 = 4,
3508
+ RENDERING = 5,
3509
+ ABORTING = 11,
3510
+ CLOSING = 12,
3433
3511
  CLOSED = 13,
3512
+ PRERENDER = 21,
3434
3513
  currentRequest = null,
3435
3514
  debugID = null,
3436
3515
  modelRoot = !1,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-server-dom-webpack",
3
3
  "description": "React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
4
- "version": "19.0.0-rc-e56f4ae3-20240830",
4
+ "version": "19.0.0-rc-4f604941-20240830",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],
@@ -99,8 +99,8 @@
99
99
  "node": ">=0.10.0"
100
100
  },
101
101
  "peerDependencies": {
102
- "react": "19.0.0-rc-e56f4ae3-20240830",
103
- "react-dom": "19.0.0-rc-e56f4ae3-20240830",
102
+ "react": "19.0.0-rc-4f604941-20240830",
103
+ "react-dom": "19.0.0-rc-4f604941-20240830",
104
104
  "webpack": "^5.59.0"
105
105
  },
106
106
  "dependencies": {