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.
@@ -1299,7 +1299,7 @@ function resolveTypedArray(
1299
1299
  );
1300
1300
  resolveBuffer(response, id, constructor);
1301
1301
  }
1302
- function processFullRow(response, id, tag, buffer, chunk) {
1302
+ function processFullBinaryRow(response, id, tag, buffer, chunk) {
1303
1303
  switch (tag) {
1304
1304
  case 65:
1305
1305
  resolveBuffer(response, id, mergeBuffer(buffer, chunk).buffer);
@@ -1352,6 +1352,9 @@ function processFullRow(response, id, tag, buffer, chunk) {
1352
1352
  )
1353
1353
  row += stringDecoder.decode(buffer[i], decoderOptions);
1354
1354
  row += stringDecoder.decode(chunk);
1355
+ processFullStringRow(response, id, tag, row);
1356
+ }
1357
+ function processFullStringRow(response, id, tag, row) {
1355
1358
  switch (tag) {
1356
1359
  case 73:
1357
1360
  resolveModule(response, id, row);
@@ -1408,14 +1411,15 @@ function processFullRow(response, id, tag, buffer, chunk) {
1408
1411
  row.stack = "Error: " + row.message;
1409
1412
  row.digest = tag;
1410
1413
  tag = response._chunks;
1411
- (buffer = tag.get(id))
1412
- ? triggerErrorOnChunk(buffer, row)
1414
+ var chunk = tag.get(id);
1415
+ chunk
1416
+ ? triggerErrorOnChunk(chunk, row)
1413
1417
  : tag.set(id, new Chunk("rejected", null, row, response));
1414
1418
  break;
1415
1419
  case 84:
1416
1420
  tag = response._chunks;
1417
- (buffer = tag.get(id)) && "pending" !== buffer.status
1418
- ? buffer.reason.enqueueValue(row)
1421
+ (chunk = tag.get(id)) && "pending" !== chunk.status
1422
+ ? chunk.reason.enqueueValue(row)
1419
1423
  : tag.set(id, new Chunk("fulfilled", row, null, response));
1420
1424
  break;
1421
1425
  case 68:
@@ -1442,8 +1446,8 @@ function processFullRow(response, id, tag, buffer, chunk) {
1442
1446
  break;
1443
1447
  default:
1444
1448
  (tag = response._chunks),
1445
- (buffer = tag.get(id))
1446
- ? resolveModelChunk(buffer, row)
1449
+ (chunk = tag.get(id))
1450
+ ? resolveModelChunk(chunk, row)
1447
1451
  : tag.set(id, new Chunk("resolved_model", row, null, response));
1448
1452
  }
1449
1453
  }
@@ -1497,82 +1501,175 @@ exports.createFromNodeStream = function (stream, ssrManifest, options) {
1497
1501
  void 0
1498
1502
  );
1499
1503
  stream.on("data", function (chunk) {
1500
- for (
1501
- var i = 0,
1502
- rowState = response._rowState,
1503
- rowID = response._rowID,
1504
- rowTag = response._rowTag,
1505
- rowLength = response._rowLength,
1506
- buffer = response._buffer,
1507
- chunkLength = chunk.length;
1508
- i < chunkLength;
1504
+ if ("string" === typeof chunk) {
1505
+ for (
1506
+ var i = 0,
1507
+ rowState = response._rowState,
1508
+ rowID = response._rowID,
1509
+ rowTag = response._rowTag,
1510
+ rowLength = response._rowLength,
1511
+ buffer = response._buffer,
1512
+ chunkLength = chunk.length;
1513
+ i < chunkLength;
1509
1514
 
1510
- ) {
1511
- var lastIdx = -1;
1512
- switch (rowState) {
1513
- case 0:
1514
- lastIdx = chunk[i++];
1515
- 58 === lastIdx
1516
- ? (rowState = 1)
1517
- : (rowID =
1518
- (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1519
- continue;
1520
- case 1:
1521
- rowState = chunk[i];
1522
- 84 === rowState ||
1523
- 65 === rowState ||
1524
- 79 === rowState ||
1525
- 111 === rowState ||
1526
- 85 === rowState ||
1527
- 83 === rowState ||
1528
- 115 === rowState ||
1529
- 76 === rowState ||
1530
- 108 === rowState ||
1531
- 71 === rowState ||
1532
- 103 === rowState ||
1533
- 77 === rowState ||
1534
- 109 === rowState ||
1535
- 86 === rowState
1536
- ? ((rowTag = rowState), (rowState = 2), i++)
1537
- : (64 < rowState && 91 > rowState) ||
1538
- 114 === rowState ||
1539
- 120 === rowState
1540
- ? ((rowTag = rowState), (rowState = 3), i++)
1541
- : ((rowTag = 0), (rowState = 3));
1542
- continue;
1543
- case 2:
1544
- lastIdx = chunk[i++];
1545
- 44 === lastIdx
1546
- ? (rowState = 4)
1547
- : (rowLength =
1548
- (rowLength << 4) |
1549
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1550
- continue;
1551
- case 3:
1552
- lastIdx = chunk.indexOf(10, i);
1553
- break;
1554
- case 4:
1555
- (lastIdx = i + rowLength), lastIdx > chunk.length && (lastIdx = -1);
1515
+ ) {
1516
+ var lastIdx = -1;
1517
+ switch (rowState) {
1518
+ case 0:
1519
+ lastIdx = chunk.charCodeAt(i++);
1520
+ 58 === lastIdx
1521
+ ? (rowState = 1)
1522
+ : (rowID =
1523
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1524
+ continue;
1525
+ case 1:
1526
+ rowState = chunk.charCodeAt(i);
1527
+ 84 === rowState ||
1528
+ 65 === rowState ||
1529
+ 79 === rowState ||
1530
+ 111 === rowState ||
1531
+ 85 === rowState ||
1532
+ 83 === rowState ||
1533
+ 115 === rowState ||
1534
+ 76 === rowState ||
1535
+ 108 === rowState ||
1536
+ 71 === rowState ||
1537
+ 103 === rowState ||
1538
+ 77 === rowState ||
1539
+ 109 === rowState ||
1540
+ 86 === rowState
1541
+ ? ((rowTag = rowState), (rowState = 2), i++)
1542
+ : (64 < rowState && 91 > rowState) ||
1543
+ 114 === rowState ||
1544
+ 120 === rowState
1545
+ ? ((rowTag = rowState), (rowState = 3), i++)
1546
+ : ((rowTag = 0), (rowState = 3));
1547
+ continue;
1548
+ case 2:
1549
+ lastIdx = chunk.charCodeAt(i++);
1550
+ 44 === lastIdx
1551
+ ? (rowState = 4)
1552
+ : (rowLength =
1553
+ (rowLength << 4) |
1554
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1555
+ continue;
1556
+ case 3:
1557
+ lastIdx = chunk.indexOf("\n", i);
1558
+ break;
1559
+ case 4:
1560
+ if (84 !== rowTag)
1561
+ throw Error(
1562
+ "Binary RSC chunks cannot be encoded as strings. This is a bug in the wiring of the React streams."
1563
+ );
1564
+ if (rowLength < chunk.length || chunk.length > 3 * rowLength)
1565
+ throw Error(
1566
+ "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."
1567
+ );
1568
+ lastIdx = chunk.length;
1569
+ }
1570
+ if (-1 < lastIdx) {
1571
+ if (0 < buffer.length)
1572
+ throw Error(
1573
+ "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."
1574
+ );
1575
+ i = chunk.slice(i, lastIdx);
1576
+ processFullStringRow(response, rowID, rowTag, i);
1577
+ i = lastIdx;
1578
+ 3 === rowState && i++;
1579
+ rowLength = rowID = rowTag = rowState = 0;
1580
+ buffer.length = 0;
1581
+ } else if (chunk.length !== i)
1582
+ throw Error(
1583
+ "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."
1584
+ );
1556
1585
  }
1557
- var offset = chunk.byteOffset + i;
1558
- if (-1 < lastIdx)
1559
- (rowLength = new Uint8Array(chunk.buffer, offset, lastIdx - i)),
1560
- processFullRow(response, rowID, rowTag, buffer, rowLength),
1561
- (i = lastIdx),
1562
- 3 === rowState && i++,
1563
- (rowLength = rowID = rowTag = rowState = 0),
1564
- (buffer.length = 0);
1565
- else {
1566
- chunk = new Uint8Array(chunk.buffer, offset, chunk.byteLength - i);
1567
- buffer.push(chunk);
1568
- rowLength -= chunk.byteLength;
1569
- break;
1586
+ response._rowState = rowState;
1587
+ response._rowID = rowID;
1588
+ response._rowTag = rowTag;
1589
+ response._rowLength = rowLength;
1590
+ } else {
1591
+ rowLength = 0;
1592
+ chunkLength = response._rowState;
1593
+ rowID = response._rowID;
1594
+ i = response._rowTag;
1595
+ rowState = response._rowLength;
1596
+ buffer = response._buffer;
1597
+ for (rowTag = chunk.length; rowLength < rowTag; ) {
1598
+ lastIdx = -1;
1599
+ switch (chunkLength) {
1600
+ case 0:
1601
+ lastIdx = chunk[rowLength++];
1602
+ 58 === lastIdx
1603
+ ? (chunkLength = 1)
1604
+ : (rowID =
1605
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1606
+ continue;
1607
+ case 1:
1608
+ chunkLength = chunk[rowLength];
1609
+ 84 === chunkLength ||
1610
+ 65 === chunkLength ||
1611
+ 79 === chunkLength ||
1612
+ 111 === chunkLength ||
1613
+ 85 === chunkLength ||
1614
+ 83 === chunkLength ||
1615
+ 115 === chunkLength ||
1616
+ 76 === chunkLength ||
1617
+ 108 === chunkLength ||
1618
+ 71 === chunkLength ||
1619
+ 103 === chunkLength ||
1620
+ 77 === chunkLength ||
1621
+ 109 === chunkLength ||
1622
+ 86 === chunkLength
1623
+ ? ((i = chunkLength), (chunkLength = 2), rowLength++)
1624
+ : (64 < chunkLength && 91 > chunkLength) ||
1625
+ 114 === chunkLength ||
1626
+ 120 === chunkLength
1627
+ ? ((i = chunkLength), (chunkLength = 3), rowLength++)
1628
+ : ((i = 0), (chunkLength = 3));
1629
+ continue;
1630
+ case 2:
1631
+ lastIdx = chunk[rowLength++];
1632
+ 44 === lastIdx
1633
+ ? (chunkLength = 4)
1634
+ : (rowState =
1635
+ (rowState << 4) |
1636
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1637
+ continue;
1638
+ case 3:
1639
+ lastIdx = chunk.indexOf(10, rowLength);
1640
+ break;
1641
+ case 4:
1642
+ (lastIdx = rowLength + rowState),
1643
+ lastIdx > chunk.length && (lastIdx = -1);
1644
+ }
1645
+ var offset = chunk.byteOffset + rowLength;
1646
+ if (-1 < lastIdx)
1647
+ (rowState = new Uint8Array(
1648
+ chunk.buffer,
1649
+ offset,
1650
+ lastIdx - rowLength
1651
+ )),
1652
+ processFullBinaryRow(response, rowID, i, buffer, rowState),
1653
+ (rowLength = lastIdx),
1654
+ 3 === chunkLength && rowLength++,
1655
+ (rowState = rowID = i = chunkLength = 0),
1656
+ (buffer.length = 0);
1657
+ else {
1658
+ chunk = new Uint8Array(
1659
+ chunk.buffer,
1660
+ offset,
1661
+ chunk.byteLength - rowLength
1662
+ );
1663
+ buffer.push(chunk);
1664
+ rowState -= chunk.byteLength;
1665
+ break;
1666
+ }
1570
1667
  }
1668
+ response._rowState = chunkLength;
1669
+ response._rowID = rowID;
1670
+ response._rowTag = i;
1671
+ response._rowLength = rowState;
1571
1672
  }
1572
- response._rowState = rowState;
1573
- response._rowID = rowID;
1574
- response._rowTag = rowTag;
1575
- response._rowLength = rowLength;
1576
1673
  });
1577
1674
  stream.on("error", function (error) {
1578
1675
  reportGlobalError(response, error);