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.
@@ -413,8 +413,7 @@ function createRenderState(
413
413
  segmentPrefix: stringToPrecomputedChunk(idPrefix + "S:"),
414
414
  boundaryPrefix: stringToPrecomputedChunk(idPrefix + "B:"),
415
415
  startInlineScript: inlineScriptWithNonce,
416
- htmlChunks: null,
417
- headChunks: null,
416
+ preamble: createPreambleState(),
418
417
  externalRuntimeScript: null,
419
418
  bootstrapChunks: externalRuntimeConfig,
420
419
  importMapChunks: bootstrapScriptContent,
@@ -581,6 +580,9 @@ function createResumableState(
581
580
  moduleScriptResources: {}
582
581
  };
583
582
  }
583
+ function createPreambleState() {
584
+ return { htmlChunks: null, headChunks: null, bodyChunks: null };
585
+ }
584
586
  function createFormatContext(insertionMode, selectedValue, tagScope) {
585
587
  return {
586
588
  insertionMode: insertionMode,
@@ -591,9 +593,9 @@ function createFormatContext(insertionMode, selectedValue, tagScope) {
591
593
  function createRootFormatContext(namespaceURI) {
592
594
  return createFormatContext(
593
595
  "http://www.w3.org/2000/svg" === namespaceURI
594
- ? 3
596
+ ? 4
595
597
  : "http://www.w3.org/1998/Math/MathML" === namespaceURI
596
- ? 4
598
+ ? 5
597
599
  : 0,
598
600
  null,
599
601
  0
@@ -610,33 +612,34 @@ function getChildFormatContext(parentContext, type, props) {
610
612
  parentContext.tagScope
611
613
  );
612
614
  case "svg":
613
- return createFormatContext(3, null, parentContext.tagScope);
615
+ return createFormatContext(4, null, parentContext.tagScope);
614
616
  case "picture":
615
617
  return createFormatContext(2, null, parentContext.tagScope | 2);
616
618
  case "math":
617
- return createFormatContext(4, null, parentContext.tagScope);
619
+ return createFormatContext(5, null, parentContext.tagScope);
618
620
  case "foreignObject":
619
621
  return createFormatContext(2, null, parentContext.tagScope);
620
622
  case "table":
621
- return createFormatContext(5, null, parentContext.tagScope);
623
+ return createFormatContext(6, null, parentContext.tagScope);
622
624
  case "thead":
623
625
  case "tbody":
624
626
  case "tfoot":
625
- return createFormatContext(6, null, parentContext.tagScope);
627
+ return createFormatContext(7, null, parentContext.tagScope);
626
628
  case "colgroup":
627
- return createFormatContext(8, null, parentContext.tagScope);
629
+ return createFormatContext(9, null, parentContext.tagScope);
628
630
  case "tr":
629
- return createFormatContext(7, null, parentContext.tagScope);
631
+ return createFormatContext(8, null, parentContext.tagScope);
632
+ case "head":
633
+ if (2 > parentContext.insertionMode)
634
+ return createFormatContext(3, null, parentContext.tagScope);
635
+ break;
636
+ case "html":
637
+ if (0 === parentContext.insertionMode)
638
+ return createFormatContext(1, null, parentContext.tagScope);
630
639
  }
631
- return 5 <= parentContext.insertionMode
640
+ return 6 <= parentContext.insertionMode || 2 > parentContext.insertionMode
632
641
  ? createFormatContext(2, null, parentContext.tagScope)
633
- : 0 === parentContext.insertionMode
634
- ? "html" === type
635
- ? createFormatContext(1, null, parentContext.tagScope)
636
- : createFormatContext(2, null, parentContext.tagScope)
637
- : 1 === parentContext.insertionMode
638
- ? createFormatContext(2, null, parentContext.tagScope)
639
- : parentContext;
642
+ : parentContext;
640
643
  }
641
644
  var textSeparator = stringToPrecomputedChunk("\x3c!-- --\x3e");
642
645
  function pushTextInstance(target, text, renderState, textEmbedded) {
@@ -1206,6 +1209,7 @@ function pushStartInstance(
1206
1209
  props,
1207
1210
  resumableState,
1208
1211
  renderState,
1212
+ preambleState,
1209
1213
  hoistableState,
1210
1214
  formatContext,
1211
1215
  textEmbedded,
@@ -1693,7 +1697,7 @@ function pushStartInstance(
1693
1697
  return JSCompiler_inline_result$jscomp$2;
1694
1698
  case "title":
1695
1699
  if (
1696
- 3 === formatContext.insertionMode ||
1700
+ 4 === formatContext.insertionMode ||
1697
1701
  formatContext.tagScope & 1 ||
1698
1702
  null != props.itemProp
1699
1703
  )
@@ -1712,7 +1716,7 @@ function pushStartInstance(
1712
1716
  href = props.href,
1713
1717
  precedence = props.precedence;
1714
1718
  if (
1715
- 3 === formatContext.insertionMode ||
1719
+ 4 === formatContext.insertionMode ||
1716
1720
  formatContext.tagScope & 1 ||
1717
1721
  null != props.itemProp ||
1718
1722
  "string" !== typeof rel ||
@@ -1794,7 +1798,7 @@ function pushStartInstance(
1794
1798
  "symbol" === typeof asyncProp ||
1795
1799
  props.onLoad ||
1796
1800
  props.onError ||
1797
- 3 === formatContext.insertionMode ||
1801
+ 4 === formatContext.insertionMode ||
1798
1802
  formatContext.tagScope & 1 ||
1799
1803
  null != props.itemProp
1800
1804
  )
@@ -1835,7 +1839,7 @@ function pushStartInstance(
1835
1839
  var precedence$jscomp$0 = props.precedence,
1836
1840
  href$jscomp$0 = props.href;
1837
1841
  if (
1838
- 3 === formatContext.insertionMode ||
1842
+ 4 === formatContext.insertionMode ||
1839
1843
  formatContext.tagScope & 1 ||
1840
1844
  null != props.itemProp ||
1841
1845
  "string" !== typeof precedence$jscomp$0 ||
@@ -1944,7 +1948,7 @@ function pushStartInstance(
1944
1948
  return JSCompiler_inline_result$jscomp$6;
1945
1949
  case "meta":
1946
1950
  if (
1947
- 3 === formatContext.insertionMode ||
1951
+ 4 === formatContext.insertionMode ||
1948
1952
  formatContext.tagScope & 1 ||
1949
1953
  null != props.itemProp
1950
1954
  )
@@ -2122,10 +2126,13 @@ function pushStartInstance(
2122
2126
  case "missing-glyph":
2123
2127
  break;
2124
2128
  case "head":
2125
- if (2 > formatContext.insertionMode && null === renderState.headChunks) {
2126
- renderState.headChunks = [];
2129
+ if (2 > formatContext.insertionMode) {
2130
+ var preamble = preambleState || renderState.preamble;
2131
+ if (preamble.headChunks)
2132
+ throw Error("The `<head>` tag may only be rendered once.");
2133
+ preamble.headChunks = [];
2127
2134
  var JSCompiler_inline_result$jscomp$9 = pushStartGenericElement(
2128
- renderState.headChunks,
2135
+ preamble.headChunks,
2129
2136
  props,
2130
2137
  "head"
2131
2138
  );
@@ -2136,24 +2143,42 @@ function pushStartInstance(
2136
2143
  "head"
2137
2144
  );
2138
2145
  return JSCompiler_inline_result$jscomp$9;
2139
- case "html":
2140
- if (
2141
- 0 === formatContext.insertionMode &&
2142
- null === renderState.htmlChunks
2143
- ) {
2144
- renderState.htmlChunks = [doctypeChunk];
2146
+ case "body":
2147
+ if (2 > formatContext.insertionMode) {
2148
+ var preamble$jscomp$0 = preambleState || renderState.preamble;
2149
+ if (preamble$jscomp$0.bodyChunks)
2150
+ throw Error("The `<body>` tag may only be rendered once.");
2151
+ preamble$jscomp$0.bodyChunks = [];
2145
2152
  var JSCompiler_inline_result$jscomp$10 = pushStartGenericElement(
2146
- renderState.htmlChunks,
2153
+ preamble$jscomp$0.bodyChunks,
2147
2154
  props,
2148
- "html"
2155
+ "body"
2149
2156
  );
2150
2157
  } else
2151
2158
  JSCompiler_inline_result$jscomp$10 = pushStartGenericElement(
2152
2159
  target$jscomp$0,
2153
2160
  props,
2154
- "html"
2161
+ "body"
2155
2162
  );
2156
2163
  return JSCompiler_inline_result$jscomp$10;
2164
+ case "html":
2165
+ if (0 === formatContext.insertionMode) {
2166
+ var preamble$jscomp$1 = preambleState || renderState.preamble;
2167
+ if (preamble$jscomp$1.htmlChunks)
2168
+ throw Error("The `<html>` tag may only be rendered once.");
2169
+ preamble$jscomp$1.htmlChunks = [doctypeChunk];
2170
+ var JSCompiler_inline_result$jscomp$11 = pushStartGenericElement(
2171
+ preamble$jscomp$1.htmlChunks,
2172
+ props,
2173
+ "html"
2174
+ );
2175
+ } else
2176
+ JSCompiler_inline_result$jscomp$11 = pushStartGenericElement(
2177
+ target$jscomp$0,
2178
+ props,
2179
+ "html"
2180
+ );
2181
+ return JSCompiler_inline_result$jscomp$11;
2157
2182
  default:
2158
2183
  if (-1 !== type.indexOf("-")) {
2159
2184
  target$jscomp$0.push(startChunkForTag(type));
@@ -2216,6 +2241,15 @@ function endChunkForTag(tag) {
2216
2241
  endTagCache.set(tag, chunk));
2217
2242
  return chunk;
2218
2243
  }
2244
+ function hoistPreambleState(renderState, preambleState) {
2245
+ renderState = renderState.preamble;
2246
+ null === renderState.htmlChunks &&
2247
+ (renderState.htmlChunks = preambleState.htmlChunks);
2248
+ null === renderState.headChunks &&
2249
+ (renderState.headChunks = preambleState.headChunks);
2250
+ null === renderState.bodyChunks &&
2251
+ (renderState.bodyChunks = preambleState.bodyChunks);
2252
+ }
2219
2253
  function writeBootstrap(destination, renderState) {
2220
2254
  renderState = renderState.bootstrapChunks;
2221
2255
  for (var i = 0; i < renderState.length - 1; i++)
@@ -2287,6 +2321,7 @@ function writeStartSegment(destination, renderState, formatContext, id) {
2287
2321
  switch (formatContext.insertionMode) {
2288
2322
  case 0:
2289
2323
  case 1:
2324
+ case 3:
2290
2325
  case 2:
2291
2326
  return (
2292
2327
  writeChunk(destination, startSegmentHTML),
@@ -2294,42 +2329,42 @@ function writeStartSegment(destination, renderState, formatContext, id) {
2294
2329
  writeChunk(destination, stringToChunk(id.toString(16))),
2295
2330
  writeChunkAndReturn(destination, startSegmentHTML2)
2296
2331
  );
2297
- case 3:
2332
+ case 4:
2298
2333
  return (
2299
2334
  writeChunk(destination, startSegmentSVG),
2300
2335
  writeChunk(destination, renderState.segmentPrefix),
2301
2336
  writeChunk(destination, stringToChunk(id.toString(16))),
2302
2337
  writeChunkAndReturn(destination, startSegmentSVG2)
2303
2338
  );
2304
- case 4:
2339
+ case 5:
2305
2340
  return (
2306
2341
  writeChunk(destination, startSegmentMathML),
2307
2342
  writeChunk(destination, renderState.segmentPrefix),
2308
2343
  writeChunk(destination, stringToChunk(id.toString(16))),
2309
2344
  writeChunkAndReturn(destination, startSegmentMathML2)
2310
2345
  );
2311
- case 5:
2346
+ case 6:
2312
2347
  return (
2313
2348
  writeChunk(destination, startSegmentTable),
2314
2349
  writeChunk(destination, renderState.segmentPrefix),
2315
2350
  writeChunk(destination, stringToChunk(id.toString(16))),
2316
2351
  writeChunkAndReturn(destination, startSegmentTable2)
2317
2352
  );
2318
- case 6:
2353
+ case 7:
2319
2354
  return (
2320
2355
  writeChunk(destination, startSegmentTableBody),
2321
2356
  writeChunk(destination, renderState.segmentPrefix),
2322
2357
  writeChunk(destination, stringToChunk(id.toString(16))),
2323
2358
  writeChunkAndReturn(destination, startSegmentTableBody2)
2324
2359
  );
2325
- case 7:
2360
+ case 8:
2326
2361
  return (
2327
2362
  writeChunk(destination, startSegmentTableRow),
2328
2363
  writeChunk(destination, renderState.segmentPrefix),
2329
2364
  writeChunk(destination, stringToChunk(id.toString(16))),
2330
2365
  writeChunkAndReturn(destination, startSegmentTableRow2)
2331
2366
  );
2332
- case 8:
2367
+ case 9:
2333
2368
  return (
2334
2369
  writeChunk(destination, startSegmentColGroup),
2335
2370
  writeChunk(destination, renderState.segmentPrefix),
@@ -2344,19 +2379,20 @@ function writeEndSegment(destination, formatContext) {
2344
2379
  switch (formatContext.insertionMode) {
2345
2380
  case 0:
2346
2381
  case 1:
2382
+ case 3:
2347
2383
  case 2:
2348
2384
  return writeChunkAndReturn(destination, endSegmentHTML);
2349
- case 3:
2350
- return writeChunkAndReturn(destination, endSegmentSVG);
2351
2385
  case 4:
2352
- return writeChunkAndReturn(destination, endSegmentMathML);
2386
+ return writeChunkAndReturn(destination, endSegmentSVG);
2353
2387
  case 5:
2354
- return writeChunkAndReturn(destination, endSegmentTable);
2388
+ return writeChunkAndReturn(destination, endSegmentMathML);
2355
2389
  case 6:
2356
- return writeChunkAndReturn(destination, endSegmentTableBody);
2390
+ return writeChunkAndReturn(destination, endSegmentTable);
2357
2391
  case 7:
2358
- return writeChunkAndReturn(destination, endSegmentTableRow);
2392
+ return writeChunkAndReturn(destination, endSegmentTableBody);
2359
2393
  case 8:
2394
+ return writeChunkAndReturn(destination, endSegmentTableRow);
2395
+ case 9:
2360
2396
  return writeChunkAndReturn(destination, endSegmentColGroup);
2361
2397
  default:
2362
2398
  throw Error("Unknown insertion mode. This is a bug in React.");
@@ -3875,7 +3911,7 @@ function RequestInstance(
3875
3911
  this.status = 10;
3876
3912
  this.fatalError = null;
3877
3913
  this.pendingRootTasks = this.allPendingTasks = this.nextSegmentId = 0;
3878
- this.completedRootSegment = null;
3914
+ this.completedPreambleSegments = this.completedRootSegment = null;
3879
3915
  this.abortableTasks = abortSet;
3880
3916
  this.pingedTasks = [];
3881
3917
  this.clientRenderedBoundaries = [];
@@ -3934,6 +3970,7 @@ function createRequest(
3934
3970
  null,
3935
3971
  renderState,
3936
3972
  null,
3973
+ null,
3937
3974
  resumableState.abortableTasks,
3938
3975
  null,
3939
3976
  rootFormatContext,
@@ -4001,7 +4038,12 @@ function pingTask(request, task) {
4001
4038
  return performWork(request);
4002
4039
  }, 0));
4003
4040
  }
4004
- function createSuspenseBoundary(request, fallbackAbortableTasks) {
4041
+ function createSuspenseBoundary(
4042
+ request,
4043
+ fallbackAbortableTasks,
4044
+ contentPreamble,
4045
+ fallbackPreamble
4046
+ ) {
4005
4047
  return {
4006
4048
  status: 0,
4007
4049
  rootSegmentID: -1,
@@ -4013,6 +4055,8 @@ function createSuspenseBoundary(request, fallbackAbortableTasks) {
4013
4055
  errorDigest: null,
4014
4056
  contentState: createHoistableState(),
4015
4057
  fallbackState: createHoistableState(),
4058
+ contentPreamble: contentPreamble,
4059
+ fallbackPreamble: fallbackPreamble,
4016
4060
  trackedContentKeyPath: null,
4017
4061
  trackedFallbackNode: null
4018
4062
  };
@@ -4024,6 +4068,7 @@ function createRenderTask(
4024
4068
  childIndex,
4025
4069
  blockedBoundary,
4026
4070
  blockedSegment,
4071
+ blockedPreamble,
4027
4072
  hoistableState,
4028
4073
  abortSet,
4029
4074
  keyPath,
@@ -4046,6 +4091,7 @@ function createRenderTask(
4046
4091
  },
4047
4092
  blockedBoundary: blockedBoundary,
4048
4093
  blockedSegment: blockedSegment,
4094
+ blockedPreamble: blockedPreamble,
4049
4095
  hoistableState: hoistableState,
4050
4096
  abortSet: abortSet,
4051
4097
  keyPath: keyPath,
@@ -4089,6 +4135,7 @@ function createReplayTask(
4089
4135
  },
4090
4136
  blockedBoundary: blockedBoundary,
4091
4137
  blockedSegment: null,
4138
+ blockedPreamble: null,
4092
4139
  hoistableState: hoistableState,
4093
4140
  abortSet: abortSet,
4094
4141
  keyPath: keyPath,
@@ -4112,11 +4159,12 @@ function createPendingSegment(
4112
4159
  ) {
4113
4160
  return {
4114
4161
  status: 0,
4162
+ parentFlushed: !1,
4115
4163
  id: -1,
4116
4164
  index: index,
4117
- parentFlushed: !1,
4118
4165
  chunks: [],
4119
4166
  children: [],
4167
+ preambleChildren: [],
4120
4168
  parentFormatContext: parentFormatContext,
4121
4169
  boundary: boundary,
4122
4170
  lastPushedText: lastPushedText,
@@ -4344,12 +4392,13 @@ function renderElement(request, task, keyPath, type, props, ref) {
4344
4392
  (task.formatContext = defaultProps),
4345
4393
  (task.keyPath = initialState);
4346
4394
  else {
4347
- initialState = pushStartInstance(
4395
+ ref = pushStartInstance(
4348
4396
  newProps.chunks,
4349
4397
  type,
4350
4398
  props,
4351
4399
  request.resumableState,
4352
4400
  request.renderState,
4401
+ task.blockedPreamble,
4353
4402
  task.hoistableState,
4354
4403
  task.formatContext,
4355
4404
  newProps.lastPushedText,
@@ -4357,12 +4406,42 @@ function renderElement(request, task, keyPath, type, props, ref) {
4357
4406
  );
4358
4407
  newProps.lastPushedText = !1;
4359
4408
  defaultProps = task.formatContext;
4360
- ref = task.keyPath;
4361
- task.formatContext = getChildFormatContext(defaultProps, type, props);
4409
+ initialState = task.keyPath;
4362
4410
  task.keyPath = keyPath;
4363
- renderNode(request, task, initialState, -1);
4411
+ 3 ===
4412
+ (task.formatContext = getChildFormatContext(defaultProps, type, props))
4413
+ .insertionMode
4414
+ ? ((keyPath = createPendingSegment(
4415
+ request,
4416
+ 0,
4417
+ null,
4418
+ task.formatContext,
4419
+ !1,
4420
+ !1
4421
+ )),
4422
+ newProps.preambleChildren.push(keyPath),
4423
+ (keyPath = createRenderTask(
4424
+ request,
4425
+ null,
4426
+ ref,
4427
+ -1,
4428
+ task.blockedBoundary,
4429
+ keyPath,
4430
+ task.blockedPreamble,
4431
+ task.hoistableState,
4432
+ request.abortableTasks,
4433
+ task.keyPath,
4434
+ task.formatContext,
4435
+ task.context,
4436
+ task.treeContext,
4437
+ task.componentStack,
4438
+ task.isFallback
4439
+ )),
4440
+ pushComponentStack(keyPath),
4441
+ request.pingedTasks.push(keyPath))
4442
+ : renderNode(request, task, ref, -1);
4364
4443
  task.formatContext = defaultProps;
4365
- task.keyPath = ref;
4444
+ task.keyPath = initialState;
4366
4445
  a: {
4367
4446
  task = newProps.chunks;
4368
4447
  request = request.resumableState;
@@ -4397,6 +4476,9 @@ function renderElement(request, task, keyPath, type, props, ref) {
4397
4476
  request.hasHtml = !0;
4398
4477
  break a;
4399
4478
  }
4479
+ break;
4480
+ case "head":
4481
+ if (1 >= defaultProps.insertionMode) break a;
4400
4482
  }
4401
4483
  task.push(endChunkForTag(type));
4402
4484
  }
@@ -4441,25 +4523,34 @@ function renderElement(request, task, keyPath, type, props, ref) {
4441
4523
  }
4442
4524
  } else {
4443
4525
  type = task.keyPath;
4444
- var parentBoundary = task.blockedBoundary,
4445
- parentHoistableState = task.hoistableState;
4446
- ref = task.blockedSegment;
4447
- propName$33 = props.fallback;
4526
+ var parentBoundary = task.blockedBoundary;
4527
+ ref = task.blockedPreamble;
4528
+ var parentHoistableState = task.hoistableState;
4529
+ propName$33 = task.blockedSegment;
4530
+ propName = props.fallback;
4448
4531
  props = props.children;
4449
4532
  var fallbackAbortSet = new Set();
4450
- propName = createSuspenseBoundary(request, fallbackAbortSet);
4533
+ var newBoundary =
4534
+ 2 > task.formatContext.insertionMode
4535
+ ? createSuspenseBoundary(
4536
+ request,
4537
+ fallbackAbortSet,
4538
+ createPreambleState(),
4539
+ createPreambleState()
4540
+ )
4541
+ : createSuspenseBoundary(request, fallbackAbortSet, null, null);
4451
4542
  null !== request.trackedPostpones &&
4452
- (propName.trackedContentKeyPath = keyPath);
4543
+ (newBoundary.trackedContentKeyPath = keyPath);
4453
4544
  var boundarySegment = createPendingSegment(
4454
4545
  request,
4455
- ref.chunks.length,
4456
- propName,
4546
+ propName$33.chunks.length,
4547
+ newBoundary,
4457
4548
  task.formatContext,
4458
4549
  !1,
4459
4550
  !1
4460
4551
  );
4461
- ref.children.push(boundarySegment);
4462
- ref.lastPushedText = !1;
4552
+ propName$33.children.push(boundarySegment);
4553
+ propName$33.lastPushedText = !1;
4463
4554
  var contentRootSegment = createPendingSegment(
4464
4555
  request,
4465
4556
  0,
@@ -4473,12 +4564,13 @@ function renderElement(request, task, keyPath, type, props, ref) {
4473
4564
  newProps = [keyPath[0], "Suspense Fallback", keyPath[2]];
4474
4565
  defaultProps = [newProps[1], newProps[2], [], null];
4475
4566
  request.trackedPostpones.workingMap.set(newProps, defaultProps);
4476
- propName.trackedFallbackNode = defaultProps;
4567
+ newBoundary.trackedFallbackNode = defaultProps;
4477
4568
  task.blockedSegment = boundarySegment;
4569
+ task.blockedPreamble = newBoundary.fallbackPreamble;
4478
4570
  task.keyPath = newProps;
4479
4571
  boundarySegment.status = 6;
4480
4572
  try {
4481
- renderNode(request, task, propName$33, -1),
4573
+ renderNode(request, task, propName, -1),
4482
4574
  boundarySegment.lastPushedText &&
4483
4575
  boundarySegment.textEmbedded &&
4484
4576
  boundarySegment.chunks.push(textSeparator),
@@ -4489,16 +4581,19 @@ function renderElement(request, task, keyPath, type, props, ref) {
4489
4581
  thrownValue)
4490
4582
  );
4491
4583
  } finally {
4492
- (task.blockedSegment = ref), (task.keyPath = type);
4584
+ (task.blockedSegment = propName$33),
4585
+ (task.blockedPreamble = ref),
4586
+ (task.keyPath = type);
4493
4587
  }
4494
4588
  task = createRenderTask(
4495
4589
  request,
4496
4590
  null,
4497
4591
  props,
4498
4592
  -1,
4499
- propName,
4593
+ newBoundary,
4500
4594
  contentRootSegment,
4501
- propName.contentState,
4595
+ newBoundary.contentPreamble,
4596
+ newBoundary.contentState,
4502
4597
  task.abortSet,
4503
4598
  keyPath,
4504
4599
  task.formatContext,
@@ -4510,8 +4605,9 @@ function renderElement(request, task, keyPath, type, props, ref) {
4510
4605
  pushComponentStack(task);
4511
4606
  request.pingedTasks.push(task);
4512
4607
  } else {
4513
- task.blockedBoundary = propName;
4514
- task.hoistableState = propName.contentState;
4608
+ task.blockedBoundary = newBoundary;
4609
+ task.blockedPreamble = newBoundary.contentPreamble;
4610
+ task.hoistableState = newBoundary.contentState;
4515
4611
  task.blockedSegment = contentRootSegment;
4516
4612
  task.keyPath = keyPath;
4517
4613
  contentRootSegment.status = 6;
@@ -4522,14 +4618,17 @@ function renderElement(request, task, keyPath, type, props, ref) {
4522
4618
  contentRootSegment.textEmbedded &&
4523
4619
  contentRootSegment.chunks.push(textSeparator),
4524
4620
  (contentRootSegment.status = 1),
4525
- queueCompletedSegment(propName, contentRootSegment),
4526
- 0 === propName.pendingTasks && 0 === propName.status)
4621
+ queueCompletedSegment(newBoundary, contentRootSegment),
4622
+ 0 === newBoundary.pendingTasks && 0 === newBoundary.status)
4527
4623
  ) {
4528
- propName.status = 1;
4624
+ newBoundary.status = 1;
4625
+ 0 === request.pendingRootTasks &&
4626
+ task.blockedPreamble &&
4627
+ preparePreamble(request);
4529
4628
  break a;
4530
4629
  }
4531
4630
  } catch (thrownValue$28) {
4532
- (propName.status = 4),
4631
+ (newBoundary.status = 4),
4533
4632
  12 === request.status
4534
4633
  ? ((contentRootSegment.status = 3),
4535
4634
  (newProps = request.fatalError))
@@ -4541,22 +4640,24 @@ function renderElement(request, task, keyPath, type, props, ref) {
4541
4640
  newProps,
4542
4641
  defaultProps
4543
4642
  )),
4544
- (propName.errorDigest = initialState),
4545
- untrackBoundary(request, propName);
4643
+ (newBoundary.errorDigest = initialState),
4644
+ untrackBoundary(request, newBoundary);
4546
4645
  } finally {
4547
4646
  (task.blockedBoundary = parentBoundary),
4647
+ (task.blockedPreamble = ref),
4548
4648
  (task.hoistableState = parentHoistableState),
4549
- (task.blockedSegment = ref),
4649
+ (task.blockedSegment = propName$33),
4550
4650
  (task.keyPath = type);
4551
4651
  }
4552
4652
  task = createRenderTask(
4553
4653
  request,
4554
4654
  null,
4555
- propName$33,
4655
+ propName,
4556
4656
  -1,
4557
4657
  parentBoundary,
4558
4658
  boundarySegment,
4559
- propName.fallbackState,
4659
+ newBoundary.fallbackPreamble,
4660
+ newBoundary.fallbackState,
4560
4661
  fallbackAbortSet,
4561
4662
  [keyPath[0], "Suspense Fallback", keyPath[2]],
4562
4663
  task.formatContext,
@@ -4575,9 +4676,9 @@ function renderElement(request, task, keyPath, type, props, ref) {
4575
4676
  switch (type.$$typeof) {
4576
4677
  case REACT_FORWARD_REF_TYPE:
4577
4678
  if ("ref" in props)
4578
- for (boundarySegment in ((newProps = {}), props))
4579
- "ref" !== boundarySegment &&
4580
- (newProps[boundarySegment] = props[boundarySegment]);
4679
+ for (newBoundary in ((newProps = {}), props))
4680
+ "ref" !== newBoundary &&
4681
+ (newProps[newBoundary] = props[newBoundary]);
4581
4682
  else newProps = props;
4582
4683
  type = renderWithHooks(
4583
4684
  request,
@@ -4782,17 +4883,27 @@ function retryNode(request, task) {
4782
4883
  previousReplaySet = task.replay,
4783
4884
  parentBoundary = task.blockedBoundary,
4784
4885
  parentHoistableState = task.hoistableState,
4785
- content = props.children;
4786
- props = props.fallback;
4787
- var fallbackAbortSet = new Set(),
4788
- resumedBoundary = createSuspenseBoundary(
4789
- request,
4790
- fallbackAbortSet
4791
- );
4792
- resumedBoundary.parentFlushed = !0;
4793
- resumedBoundary.rootSegmentID = type;
4794
- task.blockedBoundary = resumedBoundary;
4795
- task.hoistableState = resumedBoundary.contentState;
4886
+ content = props.children,
4887
+ fallback = props.fallback,
4888
+ fallbackAbortSet = new Set();
4889
+ props =
4890
+ 2 > task.formatContext.insertionMode
4891
+ ? createSuspenseBoundary(
4892
+ request,
4893
+ fallbackAbortSet,
4894
+ createPreambleState(),
4895
+ createPreambleState()
4896
+ )
4897
+ : createSuspenseBoundary(
4898
+ request,
4899
+ fallbackAbortSet,
4900
+ null,
4901
+ null
4902
+ );
4903
+ props.parentFlushed = !0;
4904
+ props.rootSegmentID = type;
4905
+ task.blockedBoundary = props;
4906
+ task.hoistableState = props.contentState;
4796
4907
  task.keyPath = key;
4797
4908
  task.replay = {
4798
4909
  nodes: ref,
@@ -4809,27 +4920,22 @@ function retryNode(request, task) {
4809
4920
  "Couldn't find all resumable slots by key/index during replaying. The tree doesn't match so React will fallback to client rendering."
4810
4921
  );
4811
4922
  task.replay.pendingTasks--;
4812
- if (
4813
- 0 === resumedBoundary.pendingTasks &&
4814
- 0 === resumedBoundary.status
4815
- ) {
4816
- resumedBoundary.status = 1;
4817
- request.completedBoundaries.push(resumedBoundary);
4923
+ if (0 === props.pendingTasks && 0 === props.status) {
4924
+ props.status = 1;
4925
+ request.completedBoundaries.push(props);
4818
4926
  break b;
4819
4927
  }
4820
4928
  } catch (error) {
4821
- (resumedBoundary.status = 4),
4929
+ (props.status = 4),
4822
4930
  (childNodes = getThrownInfo(task.componentStack)),
4823
4931
  (replay = logRecoverableError(
4824
4932
  request,
4825
4933
  error,
4826
4934
  childNodes
4827
4935
  )),
4828
- (resumedBoundary.errorDigest = replay),
4936
+ (props.errorDigest = replay),
4829
4937
  task.replay.pendingTasks--,
4830
- request.clientRenderedBoundaries.push(
4831
- resumedBoundary
4832
- );
4938
+ request.clientRenderedBoundaries.push(props);
4833
4939
  } finally {
4834
4940
  (task.blockedBoundary = parentBoundary),
4835
4941
  (task.hoistableState = parentHoistableState),
@@ -4844,10 +4950,10 @@ function retryNode(request, task) {
4844
4950
  slots: node$jscomp$0,
4845
4951
  pendingTasks: 0
4846
4952
  },
4847
- props,
4953
+ fallback,
4848
4954
  -1,
4849
4955
  parentBoundary,
4850
- resumedBoundary.fallbackState,
4956
+ props.fallbackState,
4851
4957
  fallbackAbortSet,
4852
4958
  [key[0], "Suspense Fallback", key[2]],
4853
4959
  task.formatContext,
@@ -5063,6 +5169,7 @@ function spawnNewSuspendedRenderTask(request, task, thenableState) {
5063
5169
  task.childIndex,
5064
5170
  task.blockedBoundary,
5065
5171
  newSegment,
5172
+ task.blockedPreamble,
5066
5173
  task.hoistableState,
5067
5174
  task.abortSet,
5068
5175
  task.keyPath,
@@ -5196,7 +5303,12 @@ function abortRemainingReplayNodes(
5196
5303
  node = node[5];
5197
5304
  var request = request$jscomp$0,
5198
5305
  errorDigest = errorDigest$jscomp$0,
5199
- resumedBoundary = createSuspenseBoundary(request, new Set());
5306
+ resumedBoundary = createSuspenseBoundary(
5307
+ request,
5308
+ new Set(),
5309
+ null,
5310
+ null
5311
+ );
5200
5312
  resumedBoundary.parentFlushed = !0;
5201
5313
  resumedBoundary.rootSegmentID = node;
5202
5314
  resumedBoundary.status = 4;
@@ -5330,6 +5442,7 @@ function safelyEmitEarlyPreloads(request, shellComplete) {
5330
5442
  }
5331
5443
  function completeShell(request) {
5332
5444
  null === request.trackedPostpones && safelyEmitEarlyPreloads(request, !0);
5445
+ null === request.trackedPostpones && preparePreamble(request);
5333
5446
  request.onShellError = noop;
5334
5447
  request = request.onShellReady;
5335
5448
  request();
@@ -5342,6 +5455,7 @@ function completeAll(request) {
5342
5455
  : null === request.completedRootSegment ||
5343
5456
  5 !== request.completedRootSegment.status
5344
5457
  );
5458
+ preparePreamble(request);
5345
5459
  request = request.onAllReady;
5346
5460
  request();
5347
5461
  }
@@ -5382,7 +5496,11 @@ function finishedTask(request, boundary, segment) {
5382
5496
  request.completedBoundaries.push(boundary),
5383
5497
  1 === boundary.status &&
5384
5498
  (boundary.fallbackAbortableTasks.forEach(abortTaskSoft, request),
5385
- boundary.fallbackAbortableTasks.clear()))
5499
+ boundary.fallbackAbortableTasks.clear(),
5500
+ 0 === request.pendingRootTasks &&
5501
+ null === request.trackedPostpones &&
5502
+ null !== boundary.contentPreamble &&
5503
+ preparePreamble(request)))
5386
5504
  : null !== segment &&
5387
5505
  segment.parentFlushed &&
5388
5506
  1 === segment.status &&
@@ -5539,9 +5657,11 @@ function performWork(request$jscomp$2) {
5539
5657
  (boundary$jscomp$0.errorDigest = request$jscomp$0),
5540
5658
  untrackBoundary(request, boundary$jscomp$0),
5541
5659
  boundary$jscomp$0.parentFlushed &&
5542
- request.clientRenderedBoundaries.push(
5543
- boundary$jscomp$0
5544
- )));
5660
+ request.clientRenderedBoundaries.push(boundary$jscomp$0),
5661
+ 0 === request.pendingRootTasks &&
5662
+ null === request.trackedPostpones &&
5663
+ null !== boundary$jscomp$0.contentPreamble &&
5664
+ preparePreamble(request)));
5545
5665
  request.allPendingTasks--;
5546
5666
  0 === request.allPendingTasks && completeAll(request);
5547
5667
  }
@@ -5564,6 +5684,85 @@ function performWork(request$jscomp$2) {
5564
5684
  }
5565
5685
  }
5566
5686
  }
5687
+ function preparePreambleFromSubtree(
5688
+ request,
5689
+ segment,
5690
+ collectedPreambleSegments
5691
+ ) {
5692
+ segment.preambleChildren.length &&
5693
+ collectedPreambleSegments.push(segment.preambleChildren);
5694
+ for (var pendingPreambles = !1, i = 0; i < segment.children.length; i++)
5695
+ pendingPreambles =
5696
+ preparePreambleFromSegment(
5697
+ request,
5698
+ segment.children[i],
5699
+ collectedPreambleSegments
5700
+ ) || pendingPreambles;
5701
+ return pendingPreambles;
5702
+ }
5703
+ function preparePreambleFromSegment(
5704
+ request,
5705
+ segment,
5706
+ collectedPreambleSegments
5707
+ ) {
5708
+ var boundary = segment.boundary;
5709
+ if (null === boundary)
5710
+ return preparePreambleFromSubtree(
5711
+ request,
5712
+ segment,
5713
+ collectedPreambleSegments
5714
+ );
5715
+ var preamble = boundary.contentPreamble,
5716
+ fallbackPreamble = boundary.fallbackPreamble;
5717
+ if (null === preamble || null === fallbackPreamble) return !1;
5718
+ switch (boundary.status) {
5719
+ case 1:
5720
+ hoistPreambleState(request.renderState, preamble);
5721
+ segment = boundary.completedSegments[0];
5722
+ if (!segment)
5723
+ throw Error(
5724
+ "A previously unvisited boundary must have exactly one root segment. This is a bug in React."
5725
+ );
5726
+ return preparePreambleFromSubtree(
5727
+ request,
5728
+ segment,
5729
+ collectedPreambleSegments
5730
+ );
5731
+ case 5:
5732
+ if (null !== request.trackedPostpones) return !0;
5733
+ case 4:
5734
+ if (1 === segment.status)
5735
+ return (
5736
+ hoistPreambleState(request.renderState, fallbackPreamble),
5737
+ preparePreambleFromSubtree(
5738
+ request,
5739
+ segment,
5740
+ collectedPreambleSegments
5741
+ )
5742
+ );
5743
+ default:
5744
+ return !0;
5745
+ }
5746
+ }
5747
+ function preparePreamble(request) {
5748
+ if (
5749
+ request.completedRootSegment &&
5750
+ null === request.completedPreambleSegments
5751
+ ) {
5752
+ var collectedPreambleSegments = [],
5753
+ hasPendingPreambles = preparePreambleFromSegment(
5754
+ request,
5755
+ request.completedRootSegment,
5756
+ collectedPreambleSegments
5757
+ ),
5758
+ preamble = request.renderState.preamble;
5759
+ if (
5760
+ !1 === hasPendingPreambles ||
5761
+ (preamble.headChunks && preamble.bodyChunks)
5762
+ )
5763
+ request.completedPreambleSegments = collectedPreambleSegments;
5764
+ }
5765
+ }
5567
5766
  function flushSubtree(request, destination, segment, hoistableState) {
5568
5767
  segment.parentFlushed = !0;
5569
5768
  switch (segment.status) {
@@ -5766,9 +5965,12 @@ function flushCompletedQueues(request, destination) {
5766
5965
  completedRootSegment = request.completedRootSegment;
5767
5966
  if (null !== completedRootSegment) {
5768
5967
  if (5 === completedRootSegment.status) return;
5968
+ var completedPreambleSegments = request.completedPreambleSegments;
5969
+ if (null === completedPreambleSegments) return;
5769
5970
  var renderState = request.renderState,
5770
- htmlChunks = renderState.htmlChunks,
5771
- headChunks = renderState.headChunks,
5971
+ preamble = renderState.preamble,
5972
+ htmlChunks = preamble.htmlChunks,
5973
+ headChunks = preamble.headChunks,
5772
5974
  i$jscomp$0;
5773
5975
  if (htmlChunks) {
5774
5976
  for (i$jscomp$0 = 0; i$jscomp$0 < htmlChunks.length; i$jscomp$0++)
@@ -5809,10 +6011,27 @@ function flushCompletedQueues(request, destination) {
5809
6011
  var hoistableChunks = renderState.hoistableChunks;
5810
6012
  for (i$jscomp$0 = 0; i$jscomp$0 < hoistableChunks.length; i$jscomp$0++)
5811
6013
  writeChunk(destination, hoistableChunks[i$jscomp$0]);
5812
- hoistableChunks.length = 0;
5813
- htmlChunks &&
5814
- null === headChunks &&
6014
+ for (
6015
+ renderState = hoistableChunks.length = 0;
6016
+ renderState < completedPreambleSegments.length;
6017
+ renderState++
6018
+ ) {
6019
+ var segments = completedPreambleSegments[renderState];
6020
+ for (preamble = 0; preamble < segments.length; preamble++)
6021
+ flushSegment(request, destination, segments[preamble], null);
6022
+ }
6023
+ var preamble$jscomp$0 = request.renderState.preamble,
6024
+ headChunks$jscomp$0 = preamble$jscomp$0.headChunks;
6025
+ (preamble$jscomp$0.htmlChunks || headChunks$jscomp$0) &&
5815
6026
  writeChunk(destination, endChunkForTag("head"));
6027
+ var bodyChunks = preamble$jscomp$0.bodyChunks;
6028
+ if (bodyChunks)
6029
+ for (
6030
+ completedPreambleSegments = 0;
6031
+ completedPreambleSegments < bodyChunks.length;
6032
+ completedPreambleSegments++
6033
+ )
6034
+ writeChunk(destination, bodyChunks[completedPreambleSegments]);
5816
6035
  flushSegment(request, destination, completedRootSegment, null);
5817
6036
  request.completedRootSegment = null;
5818
6037
  writeBootstrap(destination, request.renderState);
@@ -6046,11 +6265,11 @@ function abort(request, reason) {
6046
6265
  }
6047
6266
  function ensureCorrectIsomorphicReactVersion() {
6048
6267
  var isomorphicReactPackageVersion = React.version;
6049
- if ("19.1.0-canary-d46b04a2-20250117" !== isomorphicReactPackageVersion)
6268
+ if ("19.1.0-canary-9b62ee71-20250122" !== isomorphicReactPackageVersion)
6050
6269
  throw Error(
6051
6270
  'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
6052
6271
  (isomorphicReactPackageVersion +
6053
- "\n - react-dom: 19.1.0-canary-d46b04a2-20250117\nLearn more: https://react.dev/warnings/version-mismatch")
6272
+ "\n - react-dom: 19.1.0-canary-9b62ee71-20250122\nLearn more: https://react.dev/warnings/version-mismatch")
6054
6273
  );
6055
6274
  }
6056
6275
  ensureCorrectIsomorphicReactVersion();
@@ -6196,4 +6415,4 @@ exports.renderToReadableStream = function (children, options) {
6196
6415
  startWork(request);
6197
6416
  });
6198
6417
  };
6199
- exports.version = "19.1.0-canary-d46b04a2-20250117";
6418
+ exports.version = "19.1.0-canary-9b62ee71-20250122";