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.
@@ -1320,7 +1320,7 @@ function resolveTypedArray(
1320
1320
  );
1321
1321
  resolveBuffer(response, id, constructor);
1322
1322
  }
1323
- function processFullRow(response, id, tag, buffer, chunk) {
1323
+ function processFullBinaryRow(response, id, tag, buffer, chunk) {
1324
1324
  switch (tag) {
1325
1325
  case 65:
1326
1326
  resolveBuffer(response, id, mergeBuffer(buffer, chunk).buffer);
@@ -1373,6 +1373,9 @@ function processFullRow(response, id, tag, buffer, chunk) {
1373
1373
  )
1374
1374
  row += stringDecoder.decode(buffer[i], decoderOptions);
1375
1375
  row += stringDecoder.decode(chunk);
1376
+ processFullStringRow(response, id, tag, row);
1377
+ }
1378
+ function processFullStringRow(response, id, tag, row) {
1376
1379
  switch (tag) {
1377
1380
  case 73:
1378
1381
  resolveModule(response, id, row);
@@ -1429,14 +1432,15 @@ function processFullRow(response, id, tag, buffer, chunk) {
1429
1432
  row.stack = "Error: " + row.message;
1430
1433
  row.digest = tag;
1431
1434
  tag = response._chunks;
1432
- (buffer = tag.get(id))
1433
- ? triggerErrorOnChunk(buffer, row)
1435
+ var chunk = tag.get(id);
1436
+ chunk
1437
+ ? triggerErrorOnChunk(chunk, row)
1434
1438
  : tag.set(id, new Chunk("rejected", null, row, response));
1435
1439
  break;
1436
1440
  case 84:
1437
1441
  tag = response._chunks;
1438
- (buffer = tag.get(id)) && "pending" !== buffer.status
1439
- ? buffer.reason.enqueueValue(row)
1442
+ (chunk = tag.get(id)) && "pending" !== chunk.status
1443
+ ? chunk.reason.enqueueValue(row)
1440
1444
  : tag.set(id, new Chunk("fulfilled", row, null, response));
1441
1445
  break;
1442
1446
  case 68:
@@ -1463,8 +1467,8 @@ function processFullRow(response, id, tag, buffer, chunk) {
1463
1467
  break;
1464
1468
  default:
1465
1469
  (tag = response._chunks),
1466
- (buffer = tag.get(id))
1467
- ? resolveModelChunk(buffer, row)
1470
+ (chunk = tag.get(id))
1471
+ ? resolveModelChunk(chunk, row)
1468
1472
  : tag.set(id, new Chunk("resolved_model", row, null, response));
1469
1473
  }
1470
1474
  }
@@ -1518,82 +1522,175 @@ exports.createFromNodeStream = function (stream, ssrManifest, options) {
1518
1522
  void 0
1519
1523
  );
1520
1524
  stream.on("data", function (chunk) {
1521
- for (
1522
- var i = 0,
1523
- rowState = response._rowState,
1524
- rowID = response._rowID,
1525
- rowTag = response._rowTag,
1526
- rowLength = response._rowLength,
1527
- buffer = response._buffer,
1528
- chunkLength = chunk.length;
1529
- i < chunkLength;
1525
+ if ("string" === typeof chunk) {
1526
+ for (
1527
+ var i = 0,
1528
+ rowState = response._rowState,
1529
+ rowID = response._rowID,
1530
+ rowTag = response._rowTag,
1531
+ rowLength = response._rowLength,
1532
+ buffer = response._buffer,
1533
+ chunkLength = chunk.length;
1534
+ i < chunkLength;
1530
1535
 
1531
- ) {
1532
- var lastIdx = -1;
1533
- switch (rowState) {
1534
- case 0:
1535
- lastIdx = chunk[i++];
1536
- 58 === lastIdx
1537
- ? (rowState = 1)
1538
- : (rowID =
1539
- (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1540
- continue;
1541
- case 1:
1542
- rowState = chunk[i];
1543
- 84 === rowState ||
1544
- 65 === rowState ||
1545
- 79 === rowState ||
1546
- 111 === rowState ||
1547
- 85 === rowState ||
1548
- 83 === rowState ||
1549
- 115 === rowState ||
1550
- 76 === rowState ||
1551
- 108 === rowState ||
1552
- 71 === rowState ||
1553
- 103 === rowState ||
1554
- 77 === rowState ||
1555
- 109 === rowState ||
1556
- 86 === rowState
1557
- ? ((rowTag = rowState), (rowState = 2), i++)
1558
- : (64 < rowState && 91 > rowState) ||
1559
- 114 === rowState ||
1560
- 120 === rowState
1561
- ? ((rowTag = rowState), (rowState = 3), i++)
1562
- : ((rowTag = 0), (rowState = 3));
1563
- continue;
1564
- case 2:
1565
- lastIdx = chunk[i++];
1566
- 44 === lastIdx
1567
- ? (rowState = 4)
1568
- : (rowLength =
1569
- (rowLength << 4) |
1570
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1571
- continue;
1572
- case 3:
1573
- lastIdx = chunk.indexOf(10, i);
1574
- break;
1575
- case 4:
1576
- (lastIdx = i + rowLength), lastIdx > chunk.length && (lastIdx = -1);
1536
+ ) {
1537
+ var lastIdx = -1;
1538
+ switch (rowState) {
1539
+ case 0:
1540
+ lastIdx = chunk.charCodeAt(i++);
1541
+ 58 === lastIdx
1542
+ ? (rowState = 1)
1543
+ : (rowID =
1544
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1545
+ continue;
1546
+ case 1:
1547
+ rowState = chunk.charCodeAt(i);
1548
+ 84 === rowState ||
1549
+ 65 === rowState ||
1550
+ 79 === rowState ||
1551
+ 111 === rowState ||
1552
+ 85 === rowState ||
1553
+ 83 === rowState ||
1554
+ 115 === rowState ||
1555
+ 76 === rowState ||
1556
+ 108 === rowState ||
1557
+ 71 === rowState ||
1558
+ 103 === rowState ||
1559
+ 77 === rowState ||
1560
+ 109 === rowState ||
1561
+ 86 === rowState
1562
+ ? ((rowTag = rowState), (rowState = 2), i++)
1563
+ : (64 < rowState && 91 > rowState) ||
1564
+ 114 === rowState ||
1565
+ 120 === rowState
1566
+ ? ((rowTag = rowState), (rowState = 3), i++)
1567
+ : ((rowTag = 0), (rowState = 3));
1568
+ continue;
1569
+ case 2:
1570
+ lastIdx = chunk.charCodeAt(i++);
1571
+ 44 === lastIdx
1572
+ ? (rowState = 4)
1573
+ : (rowLength =
1574
+ (rowLength << 4) |
1575
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1576
+ continue;
1577
+ case 3:
1578
+ lastIdx = chunk.indexOf("\n", i);
1579
+ break;
1580
+ case 4:
1581
+ if (84 !== rowTag)
1582
+ throw Error(
1583
+ "Binary RSC chunks cannot be encoded as strings. This is a bug in the wiring of the React streams."
1584
+ );
1585
+ if (rowLength < chunk.length || chunk.length > 3 * rowLength)
1586
+ throw Error(
1587
+ "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."
1588
+ );
1589
+ lastIdx = chunk.length;
1590
+ }
1591
+ if (-1 < lastIdx) {
1592
+ if (0 < buffer.length)
1593
+ throw Error(
1594
+ "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."
1595
+ );
1596
+ i = chunk.slice(i, lastIdx);
1597
+ processFullStringRow(response, rowID, rowTag, i);
1598
+ i = lastIdx;
1599
+ 3 === rowState && i++;
1600
+ rowLength = rowID = rowTag = rowState = 0;
1601
+ buffer.length = 0;
1602
+ } else if (chunk.length !== i)
1603
+ throw Error(
1604
+ "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."
1605
+ );
1577
1606
  }
1578
- var offset = chunk.byteOffset + i;
1579
- if (-1 < lastIdx)
1580
- (rowLength = new Uint8Array(chunk.buffer, offset, lastIdx - i)),
1581
- processFullRow(response, rowID, rowTag, buffer, rowLength),
1582
- (i = lastIdx),
1583
- 3 === rowState && i++,
1584
- (rowLength = rowID = rowTag = rowState = 0),
1585
- (buffer.length = 0);
1586
- else {
1587
- chunk = new Uint8Array(chunk.buffer, offset, chunk.byteLength - i);
1588
- buffer.push(chunk);
1589
- rowLength -= chunk.byteLength;
1590
- break;
1607
+ response._rowState = rowState;
1608
+ response._rowID = rowID;
1609
+ response._rowTag = rowTag;
1610
+ response._rowLength = rowLength;
1611
+ } else {
1612
+ rowLength = 0;
1613
+ chunkLength = response._rowState;
1614
+ rowID = response._rowID;
1615
+ i = response._rowTag;
1616
+ rowState = response._rowLength;
1617
+ buffer = response._buffer;
1618
+ for (rowTag = chunk.length; rowLength < rowTag; ) {
1619
+ lastIdx = -1;
1620
+ switch (chunkLength) {
1621
+ case 0:
1622
+ lastIdx = chunk[rowLength++];
1623
+ 58 === lastIdx
1624
+ ? (chunkLength = 1)
1625
+ : (rowID =
1626
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1627
+ continue;
1628
+ case 1:
1629
+ chunkLength = chunk[rowLength];
1630
+ 84 === chunkLength ||
1631
+ 65 === chunkLength ||
1632
+ 79 === chunkLength ||
1633
+ 111 === chunkLength ||
1634
+ 85 === chunkLength ||
1635
+ 83 === chunkLength ||
1636
+ 115 === chunkLength ||
1637
+ 76 === chunkLength ||
1638
+ 108 === chunkLength ||
1639
+ 71 === chunkLength ||
1640
+ 103 === chunkLength ||
1641
+ 77 === chunkLength ||
1642
+ 109 === chunkLength ||
1643
+ 86 === chunkLength
1644
+ ? ((i = chunkLength), (chunkLength = 2), rowLength++)
1645
+ : (64 < chunkLength && 91 > chunkLength) ||
1646
+ 114 === chunkLength ||
1647
+ 120 === chunkLength
1648
+ ? ((i = chunkLength), (chunkLength = 3), rowLength++)
1649
+ : ((i = 0), (chunkLength = 3));
1650
+ continue;
1651
+ case 2:
1652
+ lastIdx = chunk[rowLength++];
1653
+ 44 === lastIdx
1654
+ ? (chunkLength = 4)
1655
+ : (rowState =
1656
+ (rowState << 4) |
1657
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1658
+ continue;
1659
+ case 3:
1660
+ lastIdx = chunk.indexOf(10, rowLength);
1661
+ break;
1662
+ case 4:
1663
+ (lastIdx = rowLength + rowState),
1664
+ lastIdx > chunk.length && (lastIdx = -1);
1665
+ }
1666
+ var offset = chunk.byteOffset + rowLength;
1667
+ if (-1 < lastIdx)
1668
+ (rowState = new Uint8Array(
1669
+ chunk.buffer,
1670
+ offset,
1671
+ lastIdx - rowLength
1672
+ )),
1673
+ processFullBinaryRow(response, rowID, i, buffer, rowState),
1674
+ (rowLength = lastIdx),
1675
+ 3 === chunkLength && rowLength++,
1676
+ (rowState = rowID = i = chunkLength = 0),
1677
+ (buffer.length = 0);
1678
+ else {
1679
+ chunk = new Uint8Array(
1680
+ chunk.buffer,
1681
+ offset,
1682
+ chunk.byteLength - rowLength
1683
+ );
1684
+ buffer.push(chunk);
1685
+ rowState -= chunk.byteLength;
1686
+ break;
1687
+ }
1591
1688
  }
1689
+ response._rowState = chunkLength;
1690
+ response._rowID = rowID;
1691
+ response._rowTag = i;
1692
+ response._rowLength = rowState;
1592
1693
  }
1593
- response._rowState = rowState;
1594
- response._rowID = rowID;
1595
- response._rowTag = rowTag;
1596
- response._rowLength = rowLength;
1597
1694
  });
1598
1695
  stream.on("error", function (error) {
1599
1696
  reportGlobalError(response, error);