react-server-dom-webpack 19.0.0-rc-9c6806964f-20240703 → 19.0.0-rc-f38c22b244-20240704

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.
@@ -1319,7 +1319,7 @@ function resolveTypedArray(
1319
1319
  );
1320
1320
  resolveBuffer(response, id, constructor);
1321
1321
  }
1322
- function processFullRow(response, id, tag, buffer, chunk) {
1322
+ function processFullBinaryRow(response, id, tag, buffer, chunk) {
1323
1323
  switch (tag) {
1324
1324
  case 65:
1325
1325
  resolveBuffer(response, id, mergeBuffer(buffer, chunk).buffer);
@@ -1371,44 +1371,46 @@ function processFullRow(response, id, tag, buffer, chunk) {
1371
1371
  i++
1372
1372
  )
1373
1373
  row += stringDecoder.decode(buffer[i], decoderOptions);
1374
- row += stringDecoder.decode(chunk);
1374
+ buffer = row += stringDecoder.decode(chunk);
1375
1375
  switch (tag) {
1376
1376
  case 73:
1377
- resolveModule(response, id, row);
1377
+ resolveModule(response, id, buffer);
1378
1378
  break;
1379
1379
  case 72:
1380
- id = row[0];
1381
- row = row.slice(1);
1382
- response = JSON.parse(row, response._fromJSON);
1383
- row = ReactDOMSharedInternals.d;
1380
+ id = buffer[0];
1381
+ buffer = buffer.slice(1);
1382
+ response = JSON.parse(buffer, response._fromJSON);
1383
+ buffer = ReactDOMSharedInternals.d;
1384
1384
  switch (id) {
1385
1385
  case "D":
1386
- row.D(response);
1386
+ buffer.D(response);
1387
1387
  break;
1388
1388
  case "C":
1389
1389
  "string" === typeof response
1390
- ? row.C(response)
1391
- : row.C(response[0], response[1]);
1390
+ ? buffer.C(response)
1391
+ : buffer.C(response[0], response[1]);
1392
1392
  break;
1393
1393
  case "L":
1394
1394
  id = response[0];
1395
1395
  tag = response[1];
1396
- 3 === response.length ? row.L(id, tag, response[2]) : row.L(id, tag);
1396
+ 3 === response.length
1397
+ ? buffer.L(id, tag, response[2])
1398
+ : buffer.L(id, tag);
1397
1399
  break;
1398
1400
  case "m":
1399
1401
  "string" === typeof response
1400
- ? row.m(response)
1401
- : row.m(response[0], response[1]);
1402
+ ? buffer.m(response)
1403
+ : buffer.m(response[0], response[1]);
1402
1404
  break;
1403
1405
  case "X":
1404
1406
  "string" === typeof response
1405
- ? row.X(response)
1406
- : row.X(response[0], response[1]);
1407
+ ? buffer.X(response)
1408
+ : buffer.X(response[0], response[1]);
1407
1409
  break;
1408
1410
  case "S":
1409
1411
  "string" === typeof response
1410
- ? row.S(response)
1411
- : row.S(
1412
+ ? buffer.S(response)
1413
+ : buffer.S(
1412
1414
  response[0],
1413
1415
  0 === response[1] ? void 0 : response[1],
1414
1416
  3 === response.length ? response[2] : void 0
@@ -1416,27 +1418,27 @@ function processFullRow(response, id, tag, buffer, chunk) {
1416
1418
  break;
1417
1419
  case "M":
1418
1420
  "string" === typeof response
1419
- ? row.M(response)
1420
- : row.M(response[0], response[1]);
1421
+ ? buffer.M(response)
1422
+ : buffer.M(response[0], response[1]);
1421
1423
  }
1422
1424
  break;
1423
1425
  case 69:
1424
- tag = JSON.parse(row).digest;
1425
- row = Error(
1426
+ tag = JSON.parse(buffer).digest;
1427
+ buffer = Error(
1426
1428
  "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."
1427
1429
  );
1428
- row.stack = "Error: " + row.message;
1429
- row.digest = tag;
1430
+ buffer.stack = "Error: " + buffer.message;
1431
+ buffer.digest = tag;
1430
1432
  tag = response._chunks;
1431
- (buffer = tag.get(id))
1432
- ? triggerErrorOnChunk(buffer, row)
1433
- : tag.set(id, new Chunk("rejected", null, row, response));
1433
+ (chunk = tag.get(id))
1434
+ ? triggerErrorOnChunk(chunk, buffer)
1435
+ : tag.set(id, new Chunk("rejected", null, buffer, response));
1434
1436
  break;
1435
1437
  case 84:
1436
1438
  tag = response._chunks;
1437
- (buffer = tag.get(id)) && "pending" !== buffer.status
1438
- ? buffer.reason.enqueueValue(row)
1439
- : tag.set(id, new Chunk("fulfilled", row, null, response));
1439
+ (chunk = tag.get(id)) && "pending" !== chunk.status
1440
+ ? chunk.reason.enqueueValue(buffer)
1441
+ : tag.set(id, new Chunk("fulfilled", buffer, null, response));
1440
1442
  break;
1441
1443
  case 68:
1442
1444
  case 87:
@@ -1458,13 +1460,13 @@ function processFullRow(response, id, tag, buffer, chunk) {
1458
1460
  case 67:
1459
1461
  (response = response._chunks.get(id)) &&
1460
1462
  "fulfilled" === response.status &&
1461
- response.reason.close("" === row ? '"$undefined"' : row);
1463
+ response.reason.close("" === buffer ? '"$undefined"' : buffer);
1462
1464
  break;
1463
1465
  default:
1464
1466
  (tag = response._chunks),
1465
- (buffer = tag.get(id))
1466
- ? resolveModelChunk(buffer, row)
1467
- : tag.set(id, new Chunk("resolved_model", row, null, response));
1467
+ (chunk = tag.get(id))
1468
+ ? resolveModelChunk(chunk, buffer)
1469
+ : tag.set(id, new Chunk("resolved_model", buffer, null, response));
1468
1470
  }
1469
1471
  }
1470
1472
  function createFromJSONCallback(response) {
@@ -1584,7 +1586,7 @@ function startReadingFromStream(response, stream) {
1584
1586
  var offset = value.byteOffset + i;
1585
1587
  if (-1 < lastIdx)
1586
1588
  (rowLength = new Uint8Array(value.buffer, offset, lastIdx - i)),
1587
- processFullRow(response, _ref, rowTag, buffer, rowLength),
1589
+ processFullBinaryRow(response, _ref, rowTag, buffer, rowLength),
1588
1590
  (i = lastIdx),
1589
1591
  3 === rowState && i++,
1590
1592
  (rowLength = _ref = rowTag = rowState = 0),
@@ -1433,7 +1433,8 @@
1433
1433
  encodeFormAction,
1434
1434
  nonce,
1435
1435
  temporaryReferences,
1436
- findSourceMapURL
1436
+ findSourceMapURL,
1437
+ replayConsole
1437
1438
  ) {
1438
1439
  var chunks = new Map();
1439
1440
  this._bundlerConfig = bundlerConfig;
@@ -1448,6 +1449,7 @@
1448
1449
  this._buffer = [];
1449
1450
  this._tempRefs = temporaryReferences;
1450
1451
  this._debugFindSourceMapURL = findSourceMapURL;
1452
+ this._replayConsole = replayConsole;
1451
1453
  this._fromJSON = createFromJSONCallback(this);
1452
1454
  }
1453
1455
  function resolveBuffer(response, id, buffer) {
@@ -1711,7 +1713,7 @@
1711
1713
  );
1712
1714
  resolveBuffer(response, id, constructor);
1713
1715
  }
1714
- function processFullRow(response, id, tag, buffer, chunk) {
1716
+ function processFullBinaryRow(response, id, tag, buffer, chunk) {
1715
1717
  switch (tag) {
1716
1718
  case 65:
1717
1719
  resolveBuffer(response, id, mergeBuffer(buffer, chunk).buffer);
@@ -1764,6 +1766,9 @@
1764
1766
  )
1765
1767
  row += stringDecoder.decode(buffer[i], decoderOptions);
1766
1768
  row += stringDecoder.decode(chunk);
1769
+ processFullStringRow(response, id, tag, row);
1770
+ }
1771
+ function processFullStringRow(response, id, tag, row) {
1767
1772
  switch (tag) {
1768
1773
  case 73:
1769
1774
  resolveModule(response, id, row);
@@ -1816,24 +1821,24 @@
1816
1821
  break;
1817
1822
  case 69:
1818
1823
  tag = JSON.parse(row);
1819
- buffer = tag.digest;
1820
- chunk = tag.env;
1824
+ var digest = tag.digest,
1825
+ env = tag.env;
1821
1826
  row = Error(
1822
1827
  tag.message ||
1823
1828
  "An error occurred in the Server Components render but no message was provided"
1824
1829
  );
1825
1830
  row.stack = tag.stack;
1826
- row.digest = buffer;
1827
- row.environmentName = chunk;
1831
+ row.digest = digest;
1832
+ row.environmentName = env;
1828
1833
  tag = response._chunks;
1829
- (buffer = tag.get(id))
1830
- ? triggerErrorOnChunk(buffer, row)
1834
+ (digest = tag.get(id))
1835
+ ? triggerErrorOnChunk(digest, row)
1831
1836
  : tag.set(id, new Chunk("rejected", null, row, response));
1832
1837
  break;
1833
1838
  case 84:
1834
1839
  tag = response._chunks;
1835
- (buffer = tag.get(id)) && "pending" !== buffer.status
1836
- ? buffer.reason.enqueueValue(row)
1840
+ (digest = tag.get(id)) && "pending" !== digest.status
1841
+ ? digest.reason.enqueueValue(row)
1837
1842
  : tag.set(id, new Chunk("fulfilled", row, null, response));
1838
1843
  break;
1839
1844
  case 68:
@@ -1842,46 +1847,47 @@
1842
1847
  (response._debugInfo || (response._debugInfo = [])).push(row);
1843
1848
  break;
1844
1849
  case 87:
1845
- row = JSON.parse(row, response._fromJSON);
1846
- response = row[0];
1847
- id = row[3];
1848
- tag = row.slice(4);
1849
- b: {
1850
- row = 0;
1851
- switch (response) {
1852
- case "dir":
1853
- case "dirxml":
1854
- case "groupEnd":
1855
- case "table":
1856
- console[response].apply(console, tag);
1857
- break b;
1858
- case "assert":
1859
- row = 1;
1850
+ if (response._replayConsole)
1851
+ b: {
1852
+ (row = JSON.parse(row, response._fromJSON)),
1853
+ (response = row[0]),
1854
+ (id = row[3]),
1855
+ (tag = row.slice(4)),
1856
+ (row = 0);
1857
+ switch (response) {
1858
+ case "dir":
1859
+ case "dirxml":
1860
+ case "groupEnd":
1861
+ case "table":
1862
+ console[response].apply(console, tag);
1863
+ break b;
1864
+ case "assert":
1865
+ row = 1;
1866
+ }
1867
+ tag = tag.slice(0);
1868
+ "string" === typeof tag[row]
1869
+ ? tag.splice(
1870
+ row,
1871
+ 1,
1872
+ "\u001b[0m\u001b[7m%c%s\u001b[0m%c " + tag[row],
1873
+ "background: #e6e6e6;background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));color: #000000;color: light-dark(#000000, #ffffff);border-radius: 2px",
1874
+ " " + id + " ",
1875
+ ""
1876
+ )
1877
+ : tag.splice(
1878
+ row,
1879
+ 0,
1880
+ "\u001b[0m\u001b[7m%c%s\u001b[0m%c ",
1881
+ "background: #e6e6e6;background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));color: #000000;color: light-dark(#000000, #ffffff);border-radius: 2px",
1882
+ " " + id + " ",
1883
+ ""
1884
+ );
1885
+ "error" === response
1886
+ ? error$jscomp$0.apply(console, tag)
1887
+ : "warn" === response
1888
+ ? warn.apply(console, tag)
1889
+ : console[response].apply(console, tag);
1860
1890
  }
1861
- tag = tag.slice(0);
1862
- "string" === typeof tag[row]
1863
- ? tag.splice(
1864
- row,
1865
- 1,
1866
- "\u001b[0m\u001b[7m%c%s\u001b[0m%c " + tag[row],
1867
- "background: #e6e6e6;background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));color: #000000;color: light-dark(#000000, #ffffff);border-radius: 2px",
1868
- " " + id + " ",
1869
- ""
1870
- )
1871
- : tag.splice(
1872
- row,
1873
- 0,
1874
- "\u001b[0m\u001b[7m%c%s\u001b[0m%c ",
1875
- "background: #e6e6e6;background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));color: #000000;color: light-dark(#000000, #ffffff);border-radius: 2px",
1876
- " " + id + " ",
1877
- ""
1878
- );
1879
- "error" === response
1880
- ? error$jscomp$0.apply(console, tag)
1881
- : "warn" === response
1882
- ? warn.apply(console, tag)
1883
- : console[response].apply(console, tag);
1884
- }
1885
1891
  break;
1886
1892
  case 82:
1887
1893
  startReadableStream(response, id, void 0);
@@ -1902,8 +1908,8 @@
1902
1908
  break;
1903
1909
  default:
1904
1910
  (tag = response._chunks),
1905
- (buffer = tag.get(id))
1906
- ? resolveModelChunk(buffer, row)
1911
+ (digest = tag.get(id))
1912
+ ? resolveModelChunk(digest, row)
1907
1913
  : tag.set(id, new Chunk("resolved_model", row, null, response));
1908
1914
  }
1909
1915
  }
@@ -2044,87 +2050,181 @@
2044
2050
  options ? options.encodeFormAction : void 0,
2045
2051
  options && "string" === typeof options.nonce ? options.nonce : void 0,
2046
2052
  void 0,
2047
- options && options.findSourceMapURL ? options.findSourceMapURL : void 0
2053
+ options && options.findSourceMapURL ? options.findSourceMapURL : void 0,
2054
+ options ? !0 === options.replayConsoleLogs : !1
2048
2055
  );
2049
2056
  stream.on("data", function (chunk) {
2050
- for (
2051
- var i = 0,
2052
- rowState = response._rowState,
2053
- rowID = response._rowID,
2054
- rowTag = response._rowTag,
2055
- rowLength = response._rowLength,
2056
- buffer = response._buffer,
2057
- chunkLength = chunk.length;
2058
- i < chunkLength;
2057
+ if ("string" === typeof chunk) {
2058
+ for (
2059
+ var i = 0,
2060
+ rowState = response._rowState,
2061
+ rowID = response._rowID,
2062
+ rowTag = response._rowTag,
2063
+ rowLength = response._rowLength,
2064
+ buffer = response._buffer,
2065
+ chunkLength = chunk.length;
2066
+ i < chunkLength;
2059
2067
 
2060
- ) {
2061
- var lastIdx = -1;
2062
- switch (rowState) {
2063
- case 0:
2064
- lastIdx = chunk[i++];
2065
- 58 === lastIdx
2066
- ? (rowState = 1)
2067
- : (rowID =
2068
- (rowID << 4) |
2069
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2070
- continue;
2071
- case 1:
2072
- rowState = chunk[i];
2073
- 84 === rowState ||
2074
- 65 === rowState ||
2075
- 79 === rowState ||
2076
- 111 === rowState ||
2077
- 85 === rowState ||
2078
- 83 === rowState ||
2079
- 115 === rowState ||
2080
- 76 === rowState ||
2081
- 108 === rowState ||
2082
- 71 === rowState ||
2083
- 103 === rowState ||
2084
- 77 === rowState ||
2085
- 109 === rowState ||
2086
- 86 === rowState
2087
- ? ((rowTag = rowState), (rowState = 2), i++)
2088
- : (64 < rowState && 91 > rowState) ||
2089
- 114 === rowState ||
2090
- 120 === rowState
2091
- ? ((rowTag = rowState), (rowState = 3), i++)
2092
- : ((rowTag = 0), (rowState = 3));
2093
- continue;
2094
- case 2:
2095
- lastIdx = chunk[i++];
2096
- 44 === lastIdx
2097
- ? (rowState = 4)
2098
- : (rowLength =
2099
- (rowLength << 4) |
2100
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2101
- continue;
2102
- case 3:
2103
- lastIdx = chunk.indexOf(10, i);
2104
- break;
2105
- case 4:
2106
- (lastIdx = i + rowLength),
2107
- lastIdx > chunk.length && (lastIdx = -1);
2068
+ ) {
2069
+ var lastIdx = -1;
2070
+ switch (rowState) {
2071
+ case 0:
2072
+ lastIdx = chunk.charCodeAt(i++);
2073
+ 58 === lastIdx
2074
+ ? (rowState = 1)
2075
+ : (rowID =
2076
+ (rowID << 4) |
2077
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2078
+ continue;
2079
+ case 1:
2080
+ rowState = chunk.charCodeAt(i);
2081
+ 84 === rowState ||
2082
+ 65 === rowState ||
2083
+ 79 === rowState ||
2084
+ 111 === rowState ||
2085
+ 85 === rowState ||
2086
+ 83 === rowState ||
2087
+ 115 === rowState ||
2088
+ 76 === rowState ||
2089
+ 108 === rowState ||
2090
+ 71 === rowState ||
2091
+ 103 === rowState ||
2092
+ 77 === rowState ||
2093
+ 109 === rowState ||
2094
+ 86 === rowState
2095
+ ? ((rowTag = rowState), (rowState = 2), i++)
2096
+ : (64 < rowState && 91 > rowState) ||
2097
+ 114 === rowState ||
2098
+ 120 === rowState
2099
+ ? ((rowTag = rowState), (rowState = 3), i++)
2100
+ : ((rowTag = 0), (rowState = 3));
2101
+ continue;
2102
+ case 2:
2103
+ lastIdx = chunk.charCodeAt(i++);
2104
+ 44 === lastIdx
2105
+ ? (rowState = 4)
2106
+ : (rowLength =
2107
+ (rowLength << 4) |
2108
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2109
+ continue;
2110
+ case 3:
2111
+ lastIdx = chunk.indexOf("\n", i);
2112
+ break;
2113
+ case 4:
2114
+ if (84 !== rowTag)
2115
+ throw Error(
2116
+ "Binary RSC chunks cannot be encoded as strings. This is a bug in the wiring of the React streams."
2117
+ );
2118
+ if (rowLength < chunk.length || chunk.length > 3 * rowLength)
2119
+ throw Error(
2120
+ "String chunks need to be passed in their original shape. Not split into smaller string chunks. This is a bug in the wiring of the React streams."
2121
+ );
2122
+ lastIdx = chunk.length;
2123
+ }
2124
+ if (-1 < lastIdx) {
2125
+ if (0 < buffer.length)
2126
+ throw Error(
2127
+ "String chunks need to be passed in their original shape. Not split into smaller string chunks. This is a bug in the wiring of the React streams."
2128
+ );
2129
+ i = chunk.slice(i, lastIdx);
2130
+ processFullStringRow(response, rowID, rowTag, i);
2131
+ i = lastIdx;
2132
+ 3 === rowState && i++;
2133
+ rowLength = rowID = rowTag = rowState = 0;
2134
+ buffer.length = 0;
2135
+ } else if (chunk.length !== i)
2136
+ throw Error(
2137
+ "String chunks need to be passed in their original shape. Not split into smaller string chunks. This is a bug in the wiring of the React streams."
2138
+ );
2108
2139
  }
2109
- var offset = chunk.byteOffset + i;
2110
- if (-1 < lastIdx)
2111
- (rowLength = new Uint8Array(chunk.buffer, offset, lastIdx - i)),
2112
- processFullRow(response, rowID, rowTag, buffer, rowLength),
2113
- (i = lastIdx),
2114
- 3 === rowState && i++,
2115
- (rowLength = rowID = rowTag = rowState = 0),
2116
- (buffer.length = 0);
2117
- else {
2118
- chunk = new Uint8Array(chunk.buffer, offset, chunk.byteLength - i);
2119
- buffer.push(chunk);
2120
- rowLength -= chunk.byteLength;
2121
- break;
2140
+ response._rowState = rowState;
2141
+ response._rowID = rowID;
2142
+ response._rowTag = rowTag;
2143
+ response._rowLength = rowLength;
2144
+ } else {
2145
+ rowLength = 0;
2146
+ chunkLength = response._rowState;
2147
+ rowID = response._rowID;
2148
+ i = response._rowTag;
2149
+ rowState = response._rowLength;
2150
+ buffer = response._buffer;
2151
+ for (rowTag = chunk.length; rowLength < rowTag; ) {
2152
+ lastIdx = -1;
2153
+ switch (chunkLength) {
2154
+ case 0:
2155
+ lastIdx = chunk[rowLength++];
2156
+ 58 === lastIdx
2157
+ ? (chunkLength = 1)
2158
+ : (rowID =
2159
+ (rowID << 4) |
2160
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2161
+ continue;
2162
+ case 1:
2163
+ chunkLength = chunk[rowLength];
2164
+ 84 === chunkLength ||
2165
+ 65 === chunkLength ||
2166
+ 79 === chunkLength ||
2167
+ 111 === chunkLength ||
2168
+ 85 === chunkLength ||
2169
+ 83 === chunkLength ||
2170
+ 115 === chunkLength ||
2171
+ 76 === chunkLength ||
2172
+ 108 === chunkLength ||
2173
+ 71 === chunkLength ||
2174
+ 103 === chunkLength ||
2175
+ 77 === chunkLength ||
2176
+ 109 === chunkLength ||
2177
+ 86 === chunkLength
2178
+ ? ((i = chunkLength), (chunkLength = 2), rowLength++)
2179
+ : (64 < chunkLength && 91 > chunkLength) ||
2180
+ 114 === chunkLength ||
2181
+ 120 === chunkLength
2182
+ ? ((i = chunkLength), (chunkLength = 3), rowLength++)
2183
+ : ((i = 0), (chunkLength = 3));
2184
+ continue;
2185
+ case 2:
2186
+ lastIdx = chunk[rowLength++];
2187
+ 44 === lastIdx
2188
+ ? (chunkLength = 4)
2189
+ : (rowState =
2190
+ (rowState << 4) |
2191
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2192
+ continue;
2193
+ case 3:
2194
+ lastIdx = chunk.indexOf(10, rowLength);
2195
+ break;
2196
+ case 4:
2197
+ (lastIdx = rowLength + rowState),
2198
+ lastIdx > chunk.length && (lastIdx = -1);
2199
+ }
2200
+ var offset = chunk.byteOffset + rowLength;
2201
+ if (-1 < lastIdx)
2202
+ (rowState = new Uint8Array(
2203
+ chunk.buffer,
2204
+ offset,
2205
+ lastIdx - rowLength
2206
+ )),
2207
+ processFullBinaryRow(response, rowID, i, buffer, rowState),
2208
+ (rowLength = lastIdx),
2209
+ 3 === chunkLength && rowLength++,
2210
+ (rowState = rowID = i = chunkLength = 0),
2211
+ (buffer.length = 0);
2212
+ else {
2213
+ chunk = new Uint8Array(
2214
+ chunk.buffer,
2215
+ offset,
2216
+ chunk.byteLength - rowLength
2217
+ );
2218
+ buffer.push(chunk);
2219
+ rowState -= chunk.byteLength;
2220
+ break;
2221
+ }
2122
2222
  }
2223
+ response._rowState = chunkLength;
2224
+ response._rowID = rowID;
2225
+ response._rowTag = i;
2226
+ response._rowLength = rowState;
2123
2227
  }
2124
- response._rowState = rowState;
2125
- response._rowID = rowID;
2126
- response._rowTag = rowTag;
2127
- response._rowLength = rowLength;
2128
2228
  });
2129
2229
  stream.on("error", function (error) {
2130
2230
  reportGlobalError(response, error);