react-dom 19.1.0-canary-d46b04a2-20250117 → 19.1.0-canary-9b62ee71-20250122

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.
@@ -1421,26 +1421,26 @@ function createRenderState(
1421
1421
  "React expected a positive non-zero `maxHeadersLength` option but found %s instead. When using the `onHeaders` option you may supply an optional `maxHeadersLength` option as well however, when setting this value to zero or less no headers will be captured.",
1422
1422
  0 === maxHeadersLength ? "zero" : maxHeadersLength
1423
1423
  );
1424
- importMap = {
1424
+ importMap = onHeaders
1425
+ ? {
1426
+ preconnects: "",
1427
+ fontPreloads: "",
1428
+ highImagePreloads: "",
1429
+ remainingCapacity:
1430
+ 2 + ("number" === typeof maxHeadersLength ? maxHeadersLength : 2e3)
1431
+ }
1432
+ : null;
1433
+ onHeaders = {
1425
1434
  placeholderPrefix: idPrefix + "P:",
1426
1435
  segmentPrefix: idPrefix + "S:",
1427
1436
  boundaryPrefix: idPrefix + "B:",
1428
1437
  startInlineScript: inlineScriptWithNonce,
1429
- htmlChunks: null,
1430
- headChunks: null,
1438
+ preamble: createPreambleState(),
1431
1439
  externalRuntimeScript: null,
1432
1440
  bootstrapChunks: externalRuntimeConfig,
1433
1441
  importMapChunks: bootstrapScriptContent,
1434
1442
  onHeaders: onHeaders,
1435
- headers: onHeaders
1436
- ? {
1437
- preconnects: "",
1438
- fontPreloads: "",
1439
- highImagePreloads: "",
1440
- remainingCapacity:
1441
- 2 + ("number" === typeof maxHeadersLength ? maxHeadersLength : 2e3)
1442
- }
1443
- : null,
1443
+ headers: importMap,
1444
1444
  resets: {
1445
1445
  font: {},
1446
1446
  dns: {},
@@ -1469,8 +1469,8 @@ function createRenderState(
1469
1469
  stylesToHoist: !1
1470
1470
  };
1471
1471
  if (void 0 !== bootstrapScripts)
1472
- for (onHeaders = 0; onHeaders < bootstrapScripts.length; onHeaders++) {
1473
- maxHeadersLength = bootstrapScripts[onHeaders];
1472
+ for (importMap = 0; importMap < bootstrapScripts.length; importMap++) {
1473
+ maxHeadersLength = bootstrapScripts[importMap];
1474
1474
  bootstrapScriptContent = idPrefix = void 0;
1475
1475
  var props = {
1476
1476
  rel: "preload",
@@ -1494,7 +1494,7 @@ function createRenderState(
1494
1494
  : ""));
1495
1495
  preloadBootstrapScriptOrModule(
1496
1496
  resumableState,
1497
- importMap,
1497
+ onHeaders,
1498
1498
  inlineScriptWithNonce,
1499
1499
  props
1500
1500
  );
@@ -1522,29 +1522,29 @@ function createRenderState(
1522
1522
  bootstrapScripts < bootstrapModules.length;
1523
1523
  bootstrapScripts++
1524
1524
  )
1525
- (onHeaders = bootstrapModules[bootstrapScripts]),
1525
+ (importMap = bootstrapModules[bootstrapScripts]),
1526
1526
  (idPrefix = inlineScriptWithNonce = void 0),
1527
1527
  (bootstrapScriptContent = {
1528
1528
  rel: "modulepreload",
1529
1529
  fetchPriority: "low",
1530
1530
  nonce: nonce
1531
1531
  }),
1532
- "string" === typeof onHeaders
1533
- ? (bootstrapScriptContent.href = maxHeadersLength = onHeaders)
1534
- : ((bootstrapScriptContent.href = maxHeadersLength = onHeaders.src),
1532
+ "string" === typeof importMap
1533
+ ? (bootstrapScriptContent.href = maxHeadersLength = importMap)
1534
+ : ((bootstrapScriptContent.href = maxHeadersLength = importMap.src),
1535
1535
  (bootstrapScriptContent.integrity = idPrefix =
1536
- "string" === typeof onHeaders.integrity
1537
- ? onHeaders.integrity
1536
+ "string" === typeof importMap.integrity
1537
+ ? importMap.integrity
1538
1538
  : void 0),
1539
1539
  (bootstrapScriptContent.crossOrigin = inlineScriptWithNonce =
1540
- "string" === typeof onHeaders || null == onHeaders.crossOrigin
1540
+ "string" === typeof importMap || null == importMap.crossOrigin
1541
1541
  ? void 0
1542
- : "use-credentials" === onHeaders.crossOrigin
1542
+ : "use-credentials" === importMap.crossOrigin
1543
1543
  ? "use-credentials"
1544
1544
  : "")),
1545
1545
  preloadBootstrapScriptOrModule(
1546
1546
  resumableState,
1547
- importMap,
1547
+ onHeaders,
1548
1548
  maxHeadersLength,
1549
1549
  bootstrapScriptContent
1550
1550
  ),
@@ -1565,7 +1565,7 @@ function createRenderState(
1565
1565
  escapeTextForBrowser(inlineScriptWithNonce)
1566
1566
  ),
1567
1567
  externalRuntimeConfig.push('" async="">\x3c/script>');
1568
- return importMap;
1568
+ return onHeaders;
1569
1569
  }
1570
1570
  function createResumableState(
1571
1571
  identifierPrefix,
@@ -1594,15 +1594,19 @@ function createResumableState(
1594
1594
  moduleScriptResources: {}
1595
1595
  };
1596
1596
  }
1597
+ function createPreambleState() {
1598
+ return { htmlChunks: null, headChunks: null, bodyChunks: null };
1599
+ }
1597
1600
  var ROOT_HTML_MODE = 0,
1598
1601
  HTML_HTML_MODE = 1,
1599
1602
  HTML_MODE = 2,
1600
- SVG_MODE = 3,
1601
- MATHML_MODE = 4,
1602
- HTML_TABLE_MODE = 5,
1603
- HTML_TABLE_BODY_MODE = 6,
1604
- HTML_TABLE_ROW_MODE = 7,
1605
- HTML_COLGROUP_MODE = 8;
1603
+ HTML_HEAD_MODE = 3,
1604
+ SVG_MODE = 4,
1605
+ MATHML_MODE = 5,
1606
+ HTML_TABLE_MODE = 6,
1607
+ HTML_TABLE_BODY_MODE = 7,
1608
+ HTML_TABLE_ROW_MODE = 8,
1609
+ HTML_COLGROUP_MODE = 9;
1606
1610
  function createFormatContext(insertionMode, selectedValue, tagScope) {
1607
1611
  return {
1608
1612
  insertionMode: insertionMode,
@@ -1661,16 +1665,26 @@ function getChildFormatContext(parentContext, type, props) {
1661
1665
  null,
1662
1666
  parentContext.tagScope
1663
1667
  );
1668
+ case "head":
1669
+ if (parentContext.insertionMode < HTML_MODE)
1670
+ return createFormatContext(
1671
+ HTML_HEAD_MODE,
1672
+ null,
1673
+ parentContext.tagScope
1674
+ );
1675
+ break;
1676
+ case "html":
1677
+ if (parentContext.insertionMode === ROOT_HTML_MODE)
1678
+ return createFormatContext(
1679
+ HTML_HTML_MODE,
1680
+ null,
1681
+ parentContext.tagScope
1682
+ );
1664
1683
  }
1665
- return parentContext.insertionMode >= HTML_TABLE_MODE
1684
+ return parentContext.insertionMode >= HTML_TABLE_MODE ||
1685
+ parentContext.insertionMode < HTML_MODE
1666
1686
  ? createFormatContext(HTML_MODE, null, parentContext.tagScope)
1667
- : parentContext.insertionMode === ROOT_HTML_MODE
1668
- ? "html" === type
1669
- ? createFormatContext(HTML_HTML_MODE, null, parentContext.tagScope)
1670
- : createFormatContext(HTML_MODE, null, parentContext.tagScope)
1671
- : parentContext.insertionMode === HTML_HTML_MODE
1672
- ? createFormatContext(HTML_MODE, null, parentContext.tagScope)
1673
- : parentContext;
1687
+ : parentContext;
1674
1688
  }
1675
1689
  function pushTextInstance(target, text, renderState, textEmbedded) {
1676
1690
  if ("" === text) return textEmbedded;
@@ -2364,6 +2378,7 @@ function pushStartInstance(
2364
2378
  props,
2365
2379
  resumableState,
2366
2380
  renderState,
2381
+ preambleState,
2367
2382
  hoistableState,
2368
2383
  formatContext,
2369
2384
  textEmbedded,
@@ -3498,13 +3513,13 @@ function pushStartInstance(
3498
3513
  case "missing-glyph":
3499
3514
  break;
3500
3515
  case "head":
3501
- if (
3502
- formatContext.insertionMode < HTML_MODE &&
3503
- null === renderState.headChunks
3504
- ) {
3505
- renderState.headChunks = [];
3516
+ if (formatContext.insertionMode < HTML_MODE) {
3517
+ var preamble = preambleState || renderState.preamble;
3518
+ if (preamble.headChunks)
3519
+ throw Error("The `<head>` tag may only be rendered once.");
3520
+ preamble.headChunks = [];
3506
3521
  var JSCompiler_inline_result$jscomp$9 = pushStartGenericElement(
3507
- renderState.headChunks,
3522
+ preamble.headChunks,
3508
3523
  props,
3509
3524
  "head"
3510
3525
  );
@@ -3515,24 +3530,42 @@ function pushStartInstance(
3515
3530
  "head"
3516
3531
  );
3517
3532
  return JSCompiler_inline_result$jscomp$9;
3518
- case "html":
3519
- if (
3520
- formatContext.insertionMode === ROOT_HTML_MODE &&
3521
- null === renderState.htmlChunks
3522
- ) {
3523
- renderState.htmlChunks = ["<!DOCTYPE html>"];
3533
+ case "body":
3534
+ if (formatContext.insertionMode < HTML_MODE) {
3535
+ var preamble$jscomp$0 = preambleState || renderState.preamble;
3536
+ if (preamble$jscomp$0.bodyChunks)
3537
+ throw Error("The `<body>` tag may only be rendered once.");
3538
+ preamble$jscomp$0.bodyChunks = [];
3524
3539
  var JSCompiler_inline_result$jscomp$10 = pushStartGenericElement(
3525
- renderState.htmlChunks,
3540
+ preamble$jscomp$0.bodyChunks,
3526
3541
  props,
3527
- "html"
3542
+ "body"
3528
3543
  );
3529
3544
  } else
3530
3545
  JSCompiler_inline_result$jscomp$10 = pushStartGenericElement(
3531
3546
  target$jscomp$0,
3532
3547
  props,
3533
- "html"
3548
+ "body"
3534
3549
  );
3535
3550
  return JSCompiler_inline_result$jscomp$10;
3551
+ case "html":
3552
+ if (formatContext.insertionMode === ROOT_HTML_MODE) {
3553
+ var preamble$jscomp$1 = preambleState || renderState.preamble;
3554
+ if (preamble$jscomp$1.htmlChunks)
3555
+ throw Error("The `<html>` tag may only be rendered once.");
3556
+ preamble$jscomp$1.htmlChunks = ["<!DOCTYPE html>"];
3557
+ var JSCompiler_inline_result$jscomp$11 = pushStartGenericElement(
3558
+ preamble$jscomp$1.htmlChunks,
3559
+ props,
3560
+ "html"
3561
+ );
3562
+ } else
3563
+ JSCompiler_inline_result$jscomp$11 = pushStartGenericElement(
3564
+ target$jscomp$0,
3565
+ props,
3566
+ "html"
3567
+ );
3568
+ return JSCompiler_inline_result$jscomp$11;
3536
3569
  default:
3537
3570
  if (-1 !== type.indexOf("-")) {
3538
3571
  target$jscomp$0.push(startChunkForTag(type));
@@ -3593,6 +3626,15 @@ function endChunkForTag(tag) {
3593
3626
  void 0 === chunk && ((chunk = "</" + tag + ">"), endTagCache.set(tag, chunk));
3594
3627
  return chunk;
3595
3628
  }
3629
+ function hoistPreambleState(renderState, preambleState) {
3630
+ renderState = renderState.preamble;
3631
+ null === renderState.htmlChunks &&
3632
+ (renderState.htmlChunks = preambleState.htmlChunks);
3633
+ null === renderState.headChunks &&
3634
+ (renderState.headChunks = preambleState.headChunks);
3635
+ null === renderState.bodyChunks &&
3636
+ (renderState.bodyChunks = preambleState.bodyChunks);
3637
+ }
3596
3638
  function writeBootstrap(destination, renderState) {
3597
3639
  renderState = renderState.bootstrapChunks;
3598
3640
  for (var i = 0; i < renderState.length - 1; i++)
@@ -3650,6 +3692,7 @@ function writeStartSegment(destination, renderState, formatContext, id) {
3650
3692
  switch (formatContext.insertionMode) {
3651
3693
  case ROOT_HTML_MODE:
3652
3694
  case HTML_HTML_MODE:
3695
+ case HTML_HEAD_MODE:
3653
3696
  case HTML_MODE:
3654
3697
  return (
3655
3698
  writeChunk(destination, startSegmentHTML),
@@ -3707,6 +3750,7 @@ function writeEndSegment(destination, formatContext) {
3707
3750
  switch (formatContext.insertionMode) {
3708
3751
  case ROOT_HTML_MODE:
3709
3752
  case HTML_HTML_MODE:
3753
+ case HTML_HEAD_MODE:
3710
3754
  case HTML_MODE:
3711
3755
  return !!destination.write(endSegmentHTML);
3712
3756
  case SVG_MODE:
@@ -5462,7 +5506,7 @@ function RequestInstance(
5462
5506
  this.status = 10;
5463
5507
  this.fatalError = null;
5464
5508
  this.pendingRootTasks = this.allPendingTasks = this.nextSegmentId = 0;
5465
- this.completedRootSegment = null;
5509
+ this.completedPreambleSegments = this.completedRootSegment = null;
5466
5510
  this.abortableTasks = abortSet;
5467
5511
  this.pingedTasks = [];
5468
5512
  this.clientRenderedBoundaries = [];
@@ -5522,6 +5566,7 @@ function createRequest(
5522
5566
  null,
5523
5567
  renderState,
5524
5568
  null,
5569
+ null,
5525
5570
  resumableState.abortableTasks,
5526
5571
  null,
5527
5572
  rootFormatContext,
@@ -5547,7 +5592,12 @@ function pingTask(request, task) {
5547
5592
  return performWork(request);
5548
5593
  }, 0));
5549
5594
  }
5550
- function createSuspenseBoundary(request, fallbackAbortableTasks) {
5595
+ function createSuspenseBoundary(
5596
+ request,
5597
+ fallbackAbortableTasks,
5598
+ contentPreamble,
5599
+ fallbackPreamble
5600
+ ) {
5551
5601
  return {
5552
5602
  status: PENDING,
5553
5603
  rootSegmentID: -1,
@@ -5559,6 +5609,8 @@ function createSuspenseBoundary(request, fallbackAbortableTasks) {
5559
5609
  errorDigest: null,
5560
5610
  contentState: createHoistableState(),
5561
5611
  fallbackState: createHoistableState(),
5612
+ contentPreamble: contentPreamble,
5613
+ fallbackPreamble: fallbackPreamble,
5562
5614
  trackedContentKeyPath: null,
5563
5615
  trackedFallbackNode: null,
5564
5616
  errorMessage: null,
@@ -5573,6 +5625,7 @@ function createRenderTask(
5573
5625
  childIndex,
5574
5626
  blockedBoundary,
5575
5627
  blockedSegment,
5628
+ blockedPreamble,
5576
5629
  hoistableState,
5577
5630
  abortSet,
5578
5631
  keyPath,
@@ -5595,6 +5648,7 @@ function createRenderTask(
5595
5648
  },
5596
5649
  blockedBoundary: blockedBoundary,
5597
5650
  blockedSegment: blockedSegment,
5651
+ blockedPreamble: blockedPreamble,
5598
5652
  hoistableState: hoistableState,
5599
5653
  abortSet: abortSet,
5600
5654
  keyPath: keyPath,
@@ -5638,6 +5692,7 @@ function createReplayTask(
5638
5692
  },
5639
5693
  blockedBoundary: blockedBoundary,
5640
5694
  blockedSegment: null,
5695
+ blockedPreamble: null,
5641
5696
  hoistableState: hoistableState,
5642
5697
  abortSet: abortSet,
5643
5698
  keyPath: keyPath,
@@ -5661,11 +5716,12 @@ function createPendingSegment(
5661
5716
  ) {
5662
5717
  return {
5663
5718
  status: PENDING,
5719
+ parentFlushed: !1,
5664
5720
  id: -1,
5665
5721
  index: index,
5666
- parentFlushed: !1,
5667
5722
  chunks: [],
5668
5723
  children: [],
5724
+ preambleChildren: [],
5669
5725
  parentFormatContext: parentFormatContext,
5670
5726
  boundary: boundary,
5671
5727
  lastPushedText: lastPushedText,
@@ -6266,6 +6322,7 @@ function renderElement(request, task, keyPath, type, props, ref) {
6266
6322
  props,
6267
6323
  request.resumableState,
6268
6324
  request.renderState,
6325
+ task.blockedPreamble,
6269
6326
  task.hoistableState,
6270
6327
  task.formatContext,
6271
6328
  segment.lastPushedText,
@@ -6274,9 +6331,40 @@ function renderElement(request, task, keyPath, type, props, ref) {
6274
6331
  segment.lastPushedText = !1;
6275
6332
  var _prevContext = task.formatContext,
6276
6333
  _prevKeyPath2 = task.keyPath;
6277
- task.formatContext = getChildFormatContext(_prevContext, type, props);
6278
6334
  task.keyPath = keyPath;
6279
- renderNode(request, task, _children, -1);
6335
+ if (
6336
+ (task.formatContext = getChildFormatContext(_prevContext, type, props))
6337
+ .insertionMode === HTML_HEAD_MODE
6338
+ ) {
6339
+ var preambleSegment = createPendingSegment(
6340
+ request,
6341
+ 0,
6342
+ null,
6343
+ task.formatContext,
6344
+ !1,
6345
+ !1
6346
+ );
6347
+ segment.preambleChildren.push(preambleSegment);
6348
+ var preambleTask = createRenderTask(
6349
+ request,
6350
+ null,
6351
+ _children,
6352
+ -1,
6353
+ task.blockedBoundary,
6354
+ preambleSegment,
6355
+ task.blockedPreamble,
6356
+ task.hoistableState,
6357
+ request.abortableTasks,
6358
+ task.keyPath,
6359
+ task.formatContext,
6360
+ task.context,
6361
+ task.treeContext,
6362
+ task.componentStack,
6363
+ task.isFallback
6364
+ );
6365
+ pushComponentStack(preambleTask);
6366
+ request.pingedTasks.push(preambleTask);
6367
+ } else renderNode(request, task, _children, -1);
6280
6368
  task.formatContext = _prevContext;
6281
6369
  task.keyPath = _prevKeyPath2;
6282
6370
  a: {
@@ -6313,6 +6401,9 @@ function renderElement(request, task, keyPath, type, props, ref) {
6313
6401
  resumableState.hasHtml = !0;
6314
6402
  break a;
6315
6403
  }
6404
+ break;
6405
+ case "head":
6406
+ if (_prevContext.insertionMode <= HTML_HTML_MODE) break a;
6316
6407
  }
6317
6408
  target.push(endChunkForTag(type));
6318
6409
  }
@@ -6359,12 +6450,21 @@ function renderElement(request, task, keyPath, type, props, ref) {
6359
6450
  } else {
6360
6451
  var prevKeyPath$jscomp$3 = task.keyPath,
6361
6452
  parentBoundary = task.blockedBoundary,
6453
+ parentPreamble = task.blockedPreamble,
6362
6454
  parentHoistableState = task.hoistableState,
6363
6455
  parentSegment = task.blockedSegment,
6364
6456
  fallback = props.fallback,
6365
6457
  content = props.children,
6366
- fallbackAbortSet = new Set(),
6367
- newBoundary = createSuspenseBoundary(request, fallbackAbortSet);
6458
+ fallbackAbortSet = new Set();
6459
+ var newBoundary =
6460
+ task.formatContext.insertionMode < HTML_MODE
6461
+ ? createSuspenseBoundary(
6462
+ request,
6463
+ fallbackAbortSet,
6464
+ createPreambleState(),
6465
+ createPreambleState()
6466
+ )
6467
+ : createSuspenseBoundary(request, fallbackAbortSet, null, null);
6368
6468
  null !== request.trackedPostpones &&
6369
6469
  (newBoundary.trackedContentKeyPath = keyPath);
6370
6470
  var boundarySegment = createPendingSegment(
@@ -6400,6 +6500,7 @@ function renderElement(request, task, keyPath, type, props, ref) {
6400
6500
  );
6401
6501
  newBoundary.trackedFallbackNode = fallbackReplayNode;
6402
6502
  task.blockedSegment = boundarySegment;
6503
+ task.blockedPreamble = newBoundary.fallbackPreamble;
6403
6504
  task.keyPath = fallbackKeyPath;
6404
6505
  boundarySegment.status = 6;
6405
6506
  try {
@@ -6415,6 +6516,7 @@ function renderElement(request, task, keyPath, type, props, ref) {
6415
6516
  );
6416
6517
  } finally {
6417
6518
  (task.blockedSegment = parentSegment),
6519
+ (task.blockedPreamble = parentPreamble),
6418
6520
  (task.keyPath = prevKeyPath$jscomp$3);
6419
6521
  }
6420
6522
  var suspendedPrimaryTask = createRenderTask(
@@ -6424,6 +6526,7 @@ function renderElement(request, task, keyPath, type, props, ref) {
6424
6526
  -1,
6425
6527
  newBoundary,
6426
6528
  contentRootSegment,
6529
+ newBoundary.contentPreamble,
6427
6530
  newBoundary.contentState,
6428
6531
  task.abortSet,
6429
6532
  keyPath,
@@ -6437,6 +6540,7 @@ function renderElement(request, task, keyPath, type, props, ref) {
6437
6540
  request.pingedTasks.push(suspendedPrimaryTask);
6438
6541
  } else {
6439
6542
  task.blockedBoundary = newBoundary;
6543
+ task.blockedPreamble = newBoundary.contentPreamble;
6440
6544
  task.hoistableState = newBoundary.contentState;
6441
6545
  task.blockedSegment = contentRootSegment;
6442
6546
  task.keyPath = keyPath;
@@ -6453,6 +6557,9 @@ function renderElement(request, task, keyPath, type, props, ref) {
6453
6557
  newBoundary.status === PENDING)
6454
6558
  ) {
6455
6559
  newBoundary.status = COMPLETED;
6560
+ 0 === request.pendingRootTasks &&
6561
+ task.blockedPreamble &&
6562
+ preparePreamble(request);
6456
6563
  break a;
6457
6564
  }
6458
6565
  } catch (thrownValue$2) {
@@ -6473,6 +6580,7 @@ function renderElement(request, task, keyPath, type, props, ref) {
6473
6580
  untrackBoundary(request, newBoundary);
6474
6581
  } finally {
6475
6582
  (task.blockedBoundary = parentBoundary),
6583
+ (task.blockedPreamble = parentPreamble),
6476
6584
  (task.hoistableState = parentHoistableState),
6477
6585
  (task.blockedSegment = parentSegment),
6478
6586
  (task.keyPath = prevKeyPath$jscomp$3);
@@ -6484,6 +6592,7 @@ function renderElement(request, task, keyPath, type, props, ref) {
6484
6592
  -1,
6485
6593
  parentBoundary,
6486
6594
  boundarySegment,
6595
+ newBoundary.fallbackPreamble,
6487
6596
  newBoundary.fallbackState,
6488
6597
  fallbackAbortSet,
6489
6598
  [keyPath[0], "Suspense Fallback", keyPath[2]],
@@ -6738,17 +6847,27 @@ function retryNode(request, task) {
6738
6847
  previousReplaySet = task.replay,
6739
6848
  parentBoundary = task.blockedBoundary,
6740
6849
  parentHoistableState = task.hoistableState,
6741
- content = props.children;
6742
- props = props.fallback;
6743
- var fallbackAbortSet = new Set(),
6744
- resumedBoundary = createSuspenseBoundary(
6745
- request,
6746
- fallbackAbortSet
6747
- );
6748
- resumedBoundary.parentFlushed = !0;
6749
- resumedBoundary.rootSegmentID = ref;
6750
- task.blockedBoundary = resumedBoundary;
6751
- task.hoistableState = resumedBoundary.contentState;
6850
+ content = props.children,
6851
+ fallback = props.fallback,
6852
+ fallbackAbortSet = new Set();
6853
+ props =
6854
+ task.formatContext.insertionMode < HTML_MODE
6855
+ ? createSuspenseBoundary(
6856
+ request,
6857
+ fallbackAbortSet,
6858
+ createPreambleState(),
6859
+ createPreambleState()
6860
+ )
6861
+ : createSuspenseBoundary(
6862
+ request,
6863
+ fallbackAbortSet,
6864
+ null,
6865
+ null
6866
+ );
6867
+ props.parentFlushed = !0;
6868
+ props.rootSegmentID = ref;
6869
+ task.blockedBoundary = props;
6870
+ task.hoistableState = props.contentState;
6752
6871
  task.keyPath = keyPath;
6753
6872
  task.replay = {
6754
6873
  nodes: replay,
@@ -6766,15 +6885,15 @@ function retryNode(request, task) {
6766
6885
  );
6767
6886
  task.replay.pendingTasks--;
6768
6887
  if (
6769
- 0 === resumedBoundary.pendingTasks &&
6770
- resumedBoundary.status === PENDING
6888
+ 0 === props.pendingTasks &&
6889
+ props.status === PENDING
6771
6890
  ) {
6772
- resumedBoundary.status = COMPLETED;
6773
- request.completedBoundaries.push(resumedBoundary);
6891
+ props.status = COMPLETED;
6892
+ request.completedBoundaries.push(props);
6774
6893
  break a;
6775
6894
  }
6776
6895
  } catch (error) {
6777
- (resumedBoundary.status = CLIENT_RENDERED),
6896
+ (props.status = CLIENT_RENDERED),
6778
6897
  (childNodes = getThrownInfo(task.componentStack)),
6779
6898
  (type = logRecoverableError(
6780
6899
  request,
@@ -6782,14 +6901,14 @@ function retryNode(request, task) {
6782
6901
  childNodes
6783
6902
  )),
6784
6903
  encodeErrorForBoundary(
6785
- resumedBoundary,
6904
+ props,
6786
6905
  type,
6787
6906
  error,
6788
6907
  childNodes,
6789
6908
  !1
6790
6909
  ),
6791
6910
  task.replay.pendingTasks--,
6792
- request.clientRenderedBoundaries.push(resumedBoundary);
6911
+ request.clientRenderedBoundaries.push(props);
6793
6912
  } finally {
6794
6913
  (task.blockedBoundary = parentBoundary),
6795
6914
  (task.hoistableState = parentHoistableState),
@@ -6800,10 +6919,10 @@ function retryNode(request, task) {
6800
6919
  request,
6801
6920
  null,
6802
6921
  { nodes: keyOrIndex, slots: key, pendingTasks: 0 },
6803
- props,
6922
+ fallback,
6804
6923
  -1,
6805
6924
  parentBoundary,
6806
- resumedBoundary.fallbackState,
6925
+ props.fallbackState,
6807
6926
  fallbackAbortSet,
6808
6927
  [keyPath[0], "Suspense Fallback", keyPath[2]],
6809
6928
  task.formatContext,
@@ -7122,6 +7241,7 @@ function spawnNewSuspendedRenderTask(request, task, thenableState) {
7122
7241
  task.childIndex,
7123
7242
  task.blockedBoundary,
7124
7243
  newSegment,
7244
+ task.blockedPreamble,
7125
7245
  task.hoistableState,
7126
7246
  task.abortSet,
7127
7247
  task.keyPath,
@@ -7282,7 +7402,12 @@ function abortRemainingReplayNodes(
7282
7402
  errorDigest = errorDigest$jscomp$0,
7283
7403
  errorInfo = errorInfo$jscomp$0,
7284
7404
  wasAborted = aborted,
7285
- resumedBoundary = createSuspenseBoundary(request, new Set());
7405
+ resumedBoundary = createSuspenseBoundary(
7406
+ request,
7407
+ new Set(),
7408
+ null,
7409
+ null
7410
+ );
7286
7411
  resumedBoundary.parentFlushed = !0;
7287
7412
  resumedBoundary.rootSegmentID = node;
7288
7413
  resumedBoundary.status = CLIENT_RENDERED;
@@ -7430,6 +7555,7 @@ function safelyEmitEarlyPreloads(request, shellComplete) {
7430
7555
  }
7431
7556
  function completeShell(request) {
7432
7557
  null === request.trackedPostpones && safelyEmitEarlyPreloads(request, !0);
7558
+ null === request.trackedPostpones && preparePreamble(request);
7433
7559
  request.onShellError = noop;
7434
7560
  request = request.onShellReady;
7435
7561
  request();
@@ -7442,6 +7568,7 @@ function completeAll(request) {
7442
7568
  : null === request.completedRootSegment ||
7443
7569
  request.completedRootSegment.status !== POSTPONED
7444
7570
  );
7571
+ preparePreamble(request);
7445
7572
  request = request.onAllReady;
7446
7573
  request();
7447
7574
  }
@@ -7483,7 +7610,11 @@ function finishedTask(request, boundary, segment) {
7483
7610
  request.completedBoundaries.push(boundary),
7484
7611
  boundary.status === COMPLETED &&
7485
7612
  (boundary.fallbackAbortableTasks.forEach(abortTaskSoft, request),
7486
- boundary.fallbackAbortableTasks.clear()))
7613
+ boundary.fallbackAbortableTasks.clear(),
7614
+ 0 === request.pendingRootTasks &&
7615
+ null === request.trackedPostpones &&
7616
+ null !== boundary.contentPreamble &&
7617
+ preparePreamble(request)))
7487
7618
  : null !== segment &&
7488
7619
  segment.parentFlushed &&
7489
7620
  segment.status === COMPLETED &&
@@ -7649,7 +7780,11 @@ function performWork(request$jscomp$1) {
7649
7780
  ),
7650
7781
  untrackBoundary(request, boundary),
7651
7782
  boundary.parentFlushed &&
7652
- request.clientRenderedBoundaries.push(boundary)));
7783
+ request.clientRenderedBoundaries.push(boundary),
7784
+ 0 === request.pendingRootTasks &&
7785
+ null === request.trackedPostpones &&
7786
+ null !== boundary.contentPreamble &&
7787
+ preparePreamble(request)));
7653
7788
  request.allPendingTasks--;
7654
7789
  0 === request.allPendingTasks && completeAll(request);
7655
7790
  }
@@ -7675,6 +7810,85 @@ function performWork(request$jscomp$1) {
7675
7810
  }
7676
7811
  }
7677
7812
  }
7813
+ function preparePreambleFromSubtree(
7814
+ request,
7815
+ segment,
7816
+ collectedPreambleSegments
7817
+ ) {
7818
+ segment.preambleChildren.length &&
7819
+ collectedPreambleSegments.push(segment.preambleChildren);
7820
+ for (var pendingPreambles = !1, i = 0; i < segment.children.length; i++)
7821
+ pendingPreambles =
7822
+ preparePreambleFromSegment(
7823
+ request,
7824
+ segment.children[i],
7825
+ collectedPreambleSegments
7826
+ ) || pendingPreambles;
7827
+ return pendingPreambles;
7828
+ }
7829
+ function preparePreambleFromSegment(
7830
+ request,
7831
+ segment,
7832
+ collectedPreambleSegments
7833
+ ) {
7834
+ var boundary = segment.boundary;
7835
+ if (null === boundary)
7836
+ return preparePreambleFromSubtree(
7837
+ request,
7838
+ segment,
7839
+ collectedPreambleSegments
7840
+ );
7841
+ var preamble = boundary.contentPreamble,
7842
+ fallbackPreamble = boundary.fallbackPreamble;
7843
+ if (null === preamble || null === fallbackPreamble) return !1;
7844
+ switch (boundary.status) {
7845
+ case COMPLETED:
7846
+ hoistPreambleState(request.renderState, preamble);
7847
+ segment = boundary.completedSegments[0];
7848
+ if (!segment)
7849
+ throw Error(
7850
+ "A previously unvisited boundary must have exactly one root segment. This is a bug in React."
7851
+ );
7852
+ return preparePreambleFromSubtree(
7853
+ request,
7854
+ segment,
7855
+ collectedPreambleSegments
7856
+ );
7857
+ case POSTPONED:
7858
+ if (null !== request.trackedPostpones) return !0;
7859
+ case CLIENT_RENDERED:
7860
+ if (segment.status === COMPLETED)
7861
+ return (
7862
+ hoistPreambleState(request.renderState, fallbackPreamble),
7863
+ preparePreambleFromSubtree(
7864
+ request,
7865
+ segment,
7866
+ collectedPreambleSegments
7867
+ )
7868
+ );
7869
+ default:
7870
+ return !0;
7871
+ }
7872
+ }
7873
+ function preparePreamble(request) {
7874
+ if (
7875
+ request.completedRootSegment &&
7876
+ null === request.completedPreambleSegments
7877
+ ) {
7878
+ var collectedPreambleSegments = [],
7879
+ hasPendingPreambles = preparePreambleFromSegment(
7880
+ request,
7881
+ request.completedRootSegment,
7882
+ collectedPreambleSegments
7883
+ ),
7884
+ preamble = request.renderState.preamble;
7885
+ if (
7886
+ !1 === hasPendingPreambles ||
7887
+ (preamble.headChunks && preamble.bodyChunks)
7888
+ )
7889
+ request.completedPreambleSegments = collectedPreambleSegments;
7890
+ }
7891
+ }
7678
7892
  function flushSubtree(request, destination, segment, hoistableState) {
7679
7893
  segment.parentFlushed = !0;
7680
7894
  switch (segment.status) {
@@ -7905,9 +8119,12 @@ function flushCompletedQueues(request, destination) {
7905
8119
  completedRootSegment = request.completedRootSegment;
7906
8120
  if (null !== completedRootSegment) {
7907
8121
  if (completedRootSegment.status === POSTPONED) return;
8122
+ var completedPreambleSegments = request.completedPreambleSegments;
8123
+ if (null === completedPreambleSegments) return;
7908
8124
  var renderState = request.renderState,
7909
- htmlChunks = renderState.htmlChunks,
7910
- headChunks = renderState.headChunks,
8125
+ preamble = renderState.preamble,
8126
+ htmlChunks = preamble.htmlChunks,
8127
+ headChunks = preamble.headChunks,
7911
8128
  i$jscomp$0;
7912
8129
  if (htmlChunks) {
7913
8130
  for (i$jscomp$0 = 0; i$jscomp$0 < htmlChunks.length; i$jscomp$0++)
@@ -7948,10 +8165,27 @@ function flushCompletedQueues(request, destination) {
7948
8165
  var hoistableChunks = renderState.hoistableChunks;
7949
8166
  for (i$jscomp$0 = 0; i$jscomp$0 < hoistableChunks.length; i$jscomp$0++)
7950
8167
  writeChunk(destination, hoistableChunks[i$jscomp$0]);
7951
- hoistableChunks.length = 0;
7952
- htmlChunks &&
7953
- null === headChunks &&
8168
+ for (
8169
+ renderState = hoistableChunks.length = 0;
8170
+ renderState < completedPreambleSegments.length;
8171
+ renderState++
8172
+ ) {
8173
+ var segments = completedPreambleSegments[renderState];
8174
+ for (preamble = 0; preamble < segments.length; preamble++)
8175
+ flushSegment(request, destination, segments[preamble], null);
8176
+ }
8177
+ var preamble$jscomp$0 = request.renderState.preamble,
8178
+ headChunks$jscomp$0 = preamble$jscomp$0.headChunks;
8179
+ (preamble$jscomp$0.htmlChunks || headChunks$jscomp$0) &&
7954
8180
  writeChunk(destination, endChunkForTag("head"));
8181
+ var bodyChunks = preamble$jscomp$0.bodyChunks;
8182
+ if (bodyChunks)
8183
+ for (
8184
+ completedPreambleSegments = 0;
8185
+ completedPreambleSegments < bodyChunks.length;
8186
+ completedPreambleSegments++
8187
+ )
8188
+ writeChunk(destination, bodyChunks[completedPreambleSegments]);
7955
8189
  flushSegment(request, destination, completedRootSegment, null);
7956
8190
  request.completedRootSegment = null;
7957
8191
  writeBootstrap(destination, request.renderState);
@@ -8186,15 +8420,15 @@ function abort(request, reason) {
8186
8420
  logRecoverableError(request, error$4, {}), fatalError(request, error$4);
8187
8421
  }
8188
8422
  }
8189
- var isomorphicReactPackageVersion$jscomp$inline_699 = React.version;
8423
+ var isomorphicReactPackageVersion$jscomp$inline_722 = React.version;
8190
8424
  if (
8191
- "19.1.0-canary-d46b04a2-20250117" !==
8192
- isomorphicReactPackageVersion$jscomp$inline_699
8425
+ "19.1.0-canary-9b62ee71-20250122" !==
8426
+ isomorphicReactPackageVersion$jscomp$inline_722
8193
8427
  )
8194
8428
  throw Error(
8195
8429
  'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
8196
- (isomorphicReactPackageVersion$jscomp$inline_699 +
8197
- "\n - react-dom: 19.1.0-canary-d46b04a2-20250117\nLearn more: https://react.dev/warnings/version-mismatch")
8430
+ (isomorphicReactPackageVersion$jscomp$inline_722 +
8431
+ "\n - react-dom: 19.1.0-canary-9b62ee71-20250122\nLearn more: https://react.dev/warnings/version-mismatch")
8198
8432
  );
8199
8433
  exports.renderToReadableStream = function (children, options) {
8200
8434
  return new Promise(function (resolve, reject) {
@@ -8286,4 +8520,4 @@ exports.renderToReadableStream = function (children, options) {
8286
8520
  startWork(request$jscomp$0);
8287
8521
  });
8288
8522
  };
8289
- exports.version = "19.1.0-canary-d46b04a2-20250117";
8523
+ exports.version = "19.1.0-canary-9b62ee71-20250122";