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.
@@ -361,8 +361,7 @@ function createRenderState(
361
361
  segmentPrefix: stringToPrecomputedChunk(idPrefix + "S:"),
362
362
  boundaryPrefix: stringToPrecomputedChunk(idPrefix + "B:"),
363
363
  startInlineScript: inlineScriptWithNonce,
364
- htmlChunks: null,
365
- headChunks: null,
364
+ preamble: createPreambleState(),
366
365
  externalRuntimeScript: null,
367
366
  bootstrapChunks: externalRuntimeConfig,
368
367
  importMapChunks: bootstrapScriptContent,
@@ -523,6 +522,9 @@ function createResumableState(
523
522
  moduleScriptResources: {}
524
523
  };
525
524
  }
525
+ function createPreambleState() {
526
+ return { htmlChunks: null, headChunks: null, bodyChunks: null };
527
+ }
526
528
  function createFormatContext(insertionMode, selectedValue, tagScope) {
527
529
  return {
528
530
  insertionMode: insertionMode,
@@ -533,9 +535,9 @@ function createFormatContext(insertionMode, selectedValue, tagScope) {
533
535
  function createRootFormatContext(namespaceURI) {
534
536
  return createFormatContext(
535
537
  "http://www.w3.org/2000/svg" === namespaceURI
536
- ? 3
538
+ ? 4
537
539
  : "http://www.w3.org/1998/Math/MathML" === namespaceURI
538
- ? 4
540
+ ? 5
539
541
  : 0,
540
542
  null,
541
543
  0
@@ -552,33 +554,34 @@ function getChildFormatContext(parentContext, type, props) {
552
554
  parentContext.tagScope
553
555
  );
554
556
  case "svg":
555
- return createFormatContext(3, null, parentContext.tagScope);
557
+ return createFormatContext(4, null, parentContext.tagScope);
556
558
  case "picture":
557
559
  return createFormatContext(2, null, parentContext.tagScope | 2);
558
560
  case "math":
559
- return createFormatContext(4, null, parentContext.tagScope);
561
+ return createFormatContext(5, null, parentContext.tagScope);
560
562
  case "foreignObject":
561
563
  return createFormatContext(2, null, parentContext.tagScope);
562
564
  case "table":
563
- return createFormatContext(5, null, parentContext.tagScope);
565
+ return createFormatContext(6, null, parentContext.tagScope);
564
566
  case "thead":
565
567
  case "tbody":
566
568
  case "tfoot":
567
- return createFormatContext(6, null, parentContext.tagScope);
569
+ return createFormatContext(7, null, parentContext.tagScope);
568
570
  case "colgroup":
569
- return createFormatContext(8, null, parentContext.tagScope);
571
+ return createFormatContext(9, null, parentContext.tagScope);
570
572
  case "tr":
571
- return createFormatContext(7, null, parentContext.tagScope);
573
+ return createFormatContext(8, null, parentContext.tagScope);
574
+ case "head":
575
+ if (2 > parentContext.insertionMode)
576
+ return createFormatContext(3, null, parentContext.tagScope);
577
+ break;
578
+ case "html":
579
+ if (0 === parentContext.insertionMode)
580
+ return createFormatContext(1, null, parentContext.tagScope);
572
581
  }
573
- return 5 <= parentContext.insertionMode
582
+ return 6 <= parentContext.insertionMode || 2 > parentContext.insertionMode
574
583
  ? createFormatContext(2, null, parentContext.tagScope)
575
- : 0 === parentContext.insertionMode
576
- ? "html" === type
577
- ? createFormatContext(1, null, parentContext.tagScope)
578
- : createFormatContext(2, null, parentContext.tagScope)
579
- : 1 === parentContext.insertionMode
580
- ? createFormatContext(2, null, parentContext.tagScope)
581
- : parentContext;
584
+ : parentContext;
582
585
  }
583
586
  var textSeparator = stringToPrecomputedChunk("\x3c!-- --\x3e");
584
587
  function pushTextInstance(target, text, renderState, textEmbedded) {
@@ -1132,6 +1135,7 @@ function pushStartInstance(
1132
1135
  props,
1133
1136
  resumableState,
1134
1137
  renderState,
1138
+ preambleState,
1135
1139
  hoistableState,
1136
1140
  formatContext,
1137
1141
  textEmbedded,
@@ -1611,7 +1615,7 @@ function pushStartInstance(
1611
1615
  return JSCompiler_inline_result$jscomp$2;
1612
1616
  case "title":
1613
1617
  if (
1614
- 3 === formatContext.insertionMode ||
1618
+ 4 === formatContext.insertionMode ||
1615
1619
  formatContext.tagScope & 1 ||
1616
1620
  null != props.itemProp
1617
1621
  )
@@ -1630,7 +1634,7 @@ function pushStartInstance(
1630
1634
  href = props.href,
1631
1635
  precedence = props.precedence;
1632
1636
  if (
1633
- 3 === formatContext.insertionMode ||
1637
+ 4 === formatContext.insertionMode ||
1634
1638
  formatContext.tagScope & 1 ||
1635
1639
  null != props.itemProp ||
1636
1640
  "string" !== typeof rel ||
@@ -1712,7 +1716,7 @@ function pushStartInstance(
1712
1716
  "symbol" === typeof asyncProp ||
1713
1717
  props.onLoad ||
1714
1718
  props.onError ||
1715
- 3 === formatContext.insertionMode ||
1719
+ 4 === formatContext.insertionMode ||
1716
1720
  formatContext.tagScope & 1 ||
1717
1721
  null != props.itemProp
1718
1722
  )
@@ -1753,7 +1757,7 @@ function pushStartInstance(
1753
1757
  var precedence$jscomp$0 = props.precedence,
1754
1758
  href$jscomp$0 = props.href;
1755
1759
  if (
1756
- 3 === formatContext.insertionMode ||
1760
+ 4 === formatContext.insertionMode ||
1757
1761
  formatContext.tagScope & 1 ||
1758
1762
  null != props.itemProp ||
1759
1763
  "string" !== typeof precedence$jscomp$0 ||
@@ -1856,7 +1860,7 @@ function pushStartInstance(
1856
1860
  return JSCompiler_inline_result$jscomp$6;
1857
1861
  case "meta":
1858
1862
  if (
1859
- 3 === formatContext.insertionMode ||
1863
+ 4 === formatContext.insertionMode ||
1860
1864
  formatContext.tagScope & 1 ||
1861
1865
  null != props.itemProp
1862
1866
  )
@@ -2034,10 +2038,13 @@ function pushStartInstance(
2034
2038
  case "missing-glyph":
2035
2039
  break;
2036
2040
  case "head":
2037
- if (2 > formatContext.insertionMode && null === renderState.headChunks) {
2038
- renderState.headChunks = [];
2041
+ if (2 > formatContext.insertionMode) {
2042
+ var preamble = preambleState || renderState.preamble;
2043
+ if (preamble.headChunks)
2044
+ throw Error("The `<head>` tag may only be rendered once.");
2045
+ preamble.headChunks = [];
2039
2046
  var JSCompiler_inline_result$jscomp$9 = pushStartGenericElement(
2040
- renderState.headChunks,
2047
+ preamble.headChunks,
2041
2048
  props,
2042
2049
  "head"
2043
2050
  );
@@ -2048,24 +2055,42 @@ function pushStartInstance(
2048
2055
  "head"
2049
2056
  );
2050
2057
  return JSCompiler_inline_result$jscomp$9;
2051
- case "html":
2052
- if (
2053
- 0 === formatContext.insertionMode &&
2054
- null === renderState.htmlChunks
2055
- ) {
2056
- renderState.htmlChunks = [doctypeChunk];
2058
+ case "body":
2059
+ if (2 > formatContext.insertionMode) {
2060
+ var preamble$jscomp$0 = preambleState || renderState.preamble;
2061
+ if (preamble$jscomp$0.bodyChunks)
2062
+ throw Error("The `<body>` tag may only be rendered once.");
2063
+ preamble$jscomp$0.bodyChunks = [];
2057
2064
  var JSCompiler_inline_result$jscomp$10 = pushStartGenericElement(
2058
- renderState.htmlChunks,
2065
+ preamble$jscomp$0.bodyChunks,
2059
2066
  props,
2060
- "html"
2067
+ "body"
2061
2068
  );
2062
2069
  } else
2063
2070
  JSCompiler_inline_result$jscomp$10 = pushStartGenericElement(
2064
2071
  target$jscomp$0,
2065
2072
  props,
2066
- "html"
2073
+ "body"
2067
2074
  );
2068
2075
  return JSCompiler_inline_result$jscomp$10;
2076
+ case "html":
2077
+ if (0 === formatContext.insertionMode) {
2078
+ var preamble$jscomp$1 = preambleState || renderState.preamble;
2079
+ if (preamble$jscomp$1.htmlChunks)
2080
+ throw Error("The `<html>` tag may only be rendered once.");
2081
+ preamble$jscomp$1.htmlChunks = [doctypeChunk];
2082
+ var JSCompiler_inline_result$jscomp$11 = pushStartGenericElement(
2083
+ preamble$jscomp$1.htmlChunks,
2084
+ props,
2085
+ "html"
2086
+ );
2087
+ } else
2088
+ JSCompiler_inline_result$jscomp$11 = pushStartGenericElement(
2089
+ target$jscomp$0,
2090
+ props,
2091
+ "html"
2092
+ );
2093
+ return JSCompiler_inline_result$jscomp$11;
2069
2094
  default:
2070
2095
  if (-1 !== type.indexOf("-")) {
2071
2096
  target$jscomp$0.push(startChunkForTag(type));
@@ -2128,6 +2153,15 @@ function endChunkForTag(tag) {
2128
2153
  endTagCache.set(tag, chunk));
2129
2154
  return chunk;
2130
2155
  }
2156
+ function hoistPreambleState(renderState, preambleState) {
2157
+ renderState = renderState.preamble;
2158
+ null === renderState.htmlChunks &&
2159
+ (renderState.htmlChunks = preambleState.htmlChunks);
2160
+ null === renderState.headChunks &&
2161
+ (renderState.headChunks = preambleState.headChunks);
2162
+ null === renderState.bodyChunks &&
2163
+ (renderState.bodyChunks = preambleState.bodyChunks);
2164
+ }
2131
2165
  function writeBootstrap(destination, renderState) {
2132
2166
  renderState = renderState.bootstrapChunks;
2133
2167
  for (var i = 0; i < renderState.length - 1; i++)
@@ -2199,6 +2233,7 @@ function writeStartSegment(destination, renderState, formatContext, id) {
2199
2233
  switch (formatContext.insertionMode) {
2200
2234
  case 0:
2201
2235
  case 1:
2236
+ case 3:
2202
2237
  case 2:
2203
2238
  return (
2204
2239
  writeChunk(destination, startSegmentHTML),
@@ -2206,42 +2241,42 @@ function writeStartSegment(destination, renderState, formatContext, id) {
2206
2241
  writeChunk(destination, id.toString(16)),
2207
2242
  writeChunkAndReturn(destination, startSegmentHTML2)
2208
2243
  );
2209
- case 3:
2244
+ case 4:
2210
2245
  return (
2211
2246
  writeChunk(destination, startSegmentSVG),
2212
2247
  writeChunk(destination, renderState.segmentPrefix),
2213
2248
  writeChunk(destination, id.toString(16)),
2214
2249
  writeChunkAndReturn(destination, startSegmentSVG2)
2215
2250
  );
2216
- case 4:
2251
+ case 5:
2217
2252
  return (
2218
2253
  writeChunk(destination, startSegmentMathML),
2219
2254
  writeChunk(destination, renderState.segmentPrefix),
2220
2255
  writeChunk(destination, id.toString(16)),
2221
2256
  writeChunkAndReturn(destination, startSegmentMathML2)
2222
2257
  );
2223
- case 5:
2258
+ case 6:
2224
2259
  return (
2225
2260
  writeChunk(destination, startSegmentTable),
2226
2261
  writeChunk(destination, renderState.segmentPrefix),
2227
2262
  writeChunk(destination, id.toString(16)),
2228
2263
  writeChunkAndReturn(destination, startSegmentTable2)
2229
2264
  );
2230
- case 6:
2265
+ case 7:
2231
2266
  return (
2232
2267
  writeChunk(destination, startSegmentTableBody),
2233
2268
  writeChunk(destination, renderState.segmentPrefix),
2234
2269
  writeChunk(destination, id.toString(16)),
2235
2270
  writeChunkAndReturn(destination, startSegmentTableBody2)
2236
2271
  );
2237
- case 7:
2272
+ case 8:
2238
2273
  return (
2239
2274
  writeChunk(destination, startSegmentTableRow),
2240
2275
  writeChunk(destination, renderState.segmentPrefix),
2241
2276
  writeChunk(destination, id.toString(16)),
2242
2277
  writeChunkAndReturn(destination, startSegmentTableRow2)
2243
2278
  );
2244
- case 8:
2279
+ case 9:
2245
2280
  return (
2246
2281
  writeChunk(destination, startSegmentColGroup),
2247
2282
  writeChunk(destination, renderState.segmentPrefix),
@@ -2256,19 +2291,20 @@ function writeEndSegment(destination, formatContext) {
2256
2291
  switch (formatContext.insertionMode) {
2257
2292
  case 0:
2258
2293
  case 1:
2294
+ case 3:
2259
2295
  case 2:
2260
2296
  return writeChunkAndReturn(destination, endSegmentHTML);
2261
- case 3:
2262
- return writeChunkAndReturn(destination, endSegmentSVG);
2263
2297
  case 4:
2264
- return writeChunkAndReturn(destination, endSegmentMathML);
2298
+ return writeChunkAndReturn(destination, endSegmentSVG);
2265
2299
  case 5:
2266
- return writeChunkAndReturn(destination, endSegmentTable);
2300
+ return writeChunkAndReturn(destination, endSegmentMathML);
2267
2301
  case 6:
2268
- return writeChunkAndReturn(destination, endSegmentTableBody);
2302
+ return writeChunkAndReturn(destination, endSegmentTable);
2269
2303
  case 7:
2270
- return writeChunkAndReturn(destination, endSegmentTableRow);
2304
+ return writeChunkAndReturn(destination, endSegmentTableBody);
2271
2305
  case 8:
2306
+ return writeChunkAndReturn(destination, endSegmentTableRow);
2307
+ case 9:
2272
2308
  return writeChunkAndReturn(destination, endSegmentColGroup);
2273
2309
  default:
2274
2310
  throw Error("Unknown insertion mode. This is a bug in React.");
@@ -3775,7 +3811,7 @@ function RequestInstance(
3775
3811
  this.status = 10;
3776
3812
  this.fatalError = null;
3777
3813
  this.pendingRootTasks = this.allPendingTasks = this.nextSegmentId = 0;
3778
- this.completedRootSegment = null;
3814
+ this.completedPreambleSegments = this.completedRootSegment = null;
3779
3815
  this.abortableTasks = abortSet;
3780
3816
  this.pingedTasks = [];
3781
3817
  this.clientRenderedBoundaries = [];
@@ -3834,6 +3870,7 @@ function createRequest(
3834
3870
  null,
3835
3871
  renderState,
3836
3872
  null,
3873
+ null,
3837
3874
  resumableState.abortableTasks,
3838
3875
  null,
3839
3876
  rootFormatContext,
@@ -3898,7 +3935,12 @@ function pingTask(request, task) {
3898
3935
  return performWork(request);
3899
3936
  }));
3900
3937
  }
3901
- function createSuspenseBoundary(request, fallbackAbortableTasks) {
3938
+ function createSuspenseBoundary(
3939
+ request,
3940
+ fallbackAbortableTasks,
3941
+ contentPreamble,
3942
+ fallbackPreamble
3943
+ ) {
3902
3944
  return {
3903
3945
  status: 0,
3904
3946
  rootSegmentID: -1,
@@ -3910,6 +3952,8 @@ function createSuspenseBoundary(request, fallbackAbortableTasks) {
3910
3952
  errorDigest: null,
3911
3953
  contentState: createHoistableState(),
3912
3954
  fallbackState: createHoistableState(),
3955
+ contentPreamble: contentPreamble,
3956
+ fallbackPreamble: fallbackPreamble,
3913
3957
  trackedContentKeyPath: null,
3914
3958
  trackedFallbackNode: null
3915
3959
  };
@@ -3921,6 +3965,7 @@ function createRenderTask(
3921
3965
  childIndex,
3922
3966
  blockedBoundary,
3923
3967
  blockedSegment,
3968
+ blockedPreamble,
3924
3969
  hoistableState,
3925
3970
  abortSet,
3926
3971
  keyPath,
@@ -3943,6 +3988,7 @@ function createRenderTask(
3943
3988
  },
3944
3989
  blockedBoundary: blockedBoundary,
3945
3990
  blockedSegment: blockedSegment,
3991
+ blockedPreamble: blockedPreamble,
3946
3992
  hoistableState: hoistableState,
3947
3993
  abortSet: abortSet,
3948
3994
  keyPath: keyPath,
@@ -3986,6 +4032,7 @@ function createReplayTask(
3986
4032
  },
3987
4033
  blockedBoundary: blockedBoundary,
3988
4034
  blockedSegment: null,
4035
+ blockedPreamble: null,
3989
4036
  hoistableState: hoistableState,
3990
4037
  abortSet: abortSet,
3991
4038
  keyPath: keyPath,
@@ -4009,11 +4056,12 @@ function createPendingSegment(
4009
4056
  ) {
4010
4057
  return {
4011
4058
  status: 0,
4059
+ parentFlushed: !1,
4012
4060
  id: -1,
4013
4061
  index: index,
4014
- parentFlushed: !1,
4015
4062
  chunks: [],
4016
4063
  children: [],
4064
+ preambleChildren: [],
4017
4065
  parentFormatContext: parentFormatContext,
4018
4066
  boundary: boundary,
4019
4067
  lastPushedText: lastPushedText,
@@ -4241,12 +4289,13 @@ function renderElement(request, task, keyPath, type, props, ref) {
4241
4289
  (task.formatContext = defaultProps),
4242
4290
  (task.keyPath = initialState);
4243
4291
  else {
4244
- initialState = pushStartInstance(
4292
+ ref = pushStartInstance(
4245
4293
  newProps.chunks,
4246
4294
  type,
4247
4295
  props,
4248
4296
  request.resumableState,
4249
4297
  request.renderState,
4298
+ task.blockedPreamble,
4250
4299
  task.hoistableState,
4251
4300
  task.formatContext,
4252
4301
  newProps.lastPushedText,
@@ -4254,12 +4303,42 @@ function renderElement(request, task, keyPath, type, props, ref) {
4254
4303
  );
4255
4304
  newProps.lastPushedText = !1;
4256
4305
  defaultProps = task.formatContext;
4257
- ref = task.keyPath;
4258
- task.formatContext = getChildFormatContext(defaultProps, type, props);
4306
+ initialState = task.keyPath;
4259
4307
  task.keyPath = keyPath;
4260
- renderNode(request, task, initialState, -1);
4308
+ 3 ===
4309
+ (task.formatContext = getChildFormatContext(defaultProps, type, props))
4310
+ .insertionMode
4311
+ ? ((keyPath = createPendingSegment(
4312
+ request,
4313
+ 0,
4314
+ null,
4315
+ task.formatContext,
4316
+ !1,
4317
+ !1
4318
+ )),
4319
+ newProps.preambleChildren.push(keyPath),
4320
+ (keyPath = createRenderTask(
4321
+ request,
4322
+ null,
4323
+ ref,
4324
+ -1,
4325
+ task.blockedBoundary,
4326
+ keyPath,
4327
+ task.blockedPreamble,
4328
+ task.hoistableState,
4329
+ request.abortableTasks,
4330
+ task.keyPath,
4331
+ task.formatContext,
4332
+ task.context,
4333
+ task.treeContext,
4334
+ task.componentStack,
4335
+ task.isFallback
4336
+ )),
4337
+ pushComponentStack(keyPath),
4338
+ request.pingedTasks.push(keyPath))
4339
+ : renderNode(request, task, ref, -1);
4261
4340
  task.formatContext = defaultProps;
4262
- task.keyPath = ref;
4341
+ task.keyPath = initialState;
4263
4342
  a: {
4264
4343
  task = newProps.chunks;
4265
4344
  request = request.resumableState;
@@ -4294,6 +4373,9 @@ function renderElement(request, task, keyPath, type, props, ref) {
4294
4373
  request.hasHtml = !0;
4295
4374
  break a;
4296
4375
  }
4376
+ break;
4377
+ case "head":
4378
+ if (1 >= defaultProps.insertionMode) break a;
4297
4379
  }
4298
4380
  task.push(endChunkForTag(type));
4299
4381
  }
@@ -4338,25 +4420,34 @@ function renderElement(request, task, keyPath, type, props, ref) {
4338
4420
  }
4339
4421
  } else {
4340
4422
  type = task.keyPath;
4341
- var parentBoundary = task.blockedBoundary,
4342
- parentHoistableState = task.hoistableState;
4343
- ref = task.blockedSegment;
4344
- propName$33 = props.fallback;
4423
+ var parentBoundary = task.blockedBoundary;
4424
+ ref = task.blockedPreamble;
4425
+ var parentHoistableState = task.hoistableState;
4426
+ propName$33 = task.blockedSegment;
4427
+ propName = props.fallback;
4345
4428
  props = props.children;
4346
4429
  var fallbackAbortSet = new Set();
4347
- propName = createSuspenseBoundary(request, fallbackAbortSet);
4430
+ var newBoundary =
4431
+ 2 > task.formatContext.insertionMode
4432
+ ? createSuspenseBoundary(
4433
+ request,
4434
+ fallbackAbortSet,
4435
+ createPreambleState(),
4436
+ createPreambleState()
4437
+ )
4438
+ : createSuspenseBoundary(request, fallbackAbortSet, null, null);
4348
4439
  null !== request.trackedPostpones &&
4349
- (propName.trackedContentKeyPath = keyPath);
4440
+ (newBoundary.trackedContentKeyPath = keyPath);
4350
4441
  var boundarySegment = createPendingSegment(
4351
4442
  request,
4352
- ref.chunks.length,
4353
- propName,
4443
+ propName$33.chunks.length,
4444
+ newBoundary,
4354
4445
  task.formatContext,
4355
4446
  !1,
4356
4447
  !1
4357
4448
  );
4358
- ref.children.push(boundarySegment);
4359
- ref.lastPushedText = !1;
4449
+ propName$33.children.push(boundarySegment);
4450
+ propName$33.lastPushedText = !1;
4360
4451
  var contentRootSegment = createPendingSegment(
4361
4452
  request,
4362
4453
  0,
@@ -4370,12 +4461,13 @@ function renderElement(request, task, keyPath, type, props, ref) {
4370
4461
  newProps = [keyPath[0], "Suspense Fallback", keyPath[2]];
4371
4462
  defaultProps = [newProps[1], newProps[2], [], null];
4372
4463
  request.trackedPostpones.workingMap.set(newProps, defaultProps);
4373
- propName.trackedFallbackNode = defaultProps;
4464
+ newBoundary.trackedFallbackNode = defaultProps;
4374
4465
  task.blockedSegment = boundarySegment;
4466
+ task.blockedPreamble = newBoundary.fallbackPreamble;
4375
4467
  task.keyPath = newProps;
4376
4468
  boundarySegment.status = 6;
4377
4469
  try {
4378
- renderNode(request, task, propName$33, -1),
4470
+ renderNode(request, task, propName, -1),
4379
4471
  boundarySegment.lastPushedText &&
4380
4472
  boundarySegment.textEmbedded &&
4381
4473
  boundarySegment.chunks.push(textSeparator),
@@ -4386,16 +4478,19 @@ function renderElement(request, task, keyPath, type, props, ref) {
4386
4478
  thrownValue)
4387
4479
  );
4388
4480
  } finally {
4389
- (task.blockedSegment = ref), (task.keyPath = type);
4481
+ (task.blockedSegment = propName$33),
4482
+ (task.blockedPreamble = ref),
4483
+ (task.keyPath = type);
4390
4484
  }
4391
4485
  task = createRenderTask(
4392
4486
  request,
4393
4487
  null,
4394
4488
  props,
4395
4489
  -1,
4396
- propName,
4490
+ newBoundary,
4397
4491
  contentRootSegment,
4398
- propName.contentState,
4492
+ newBoundary.contentPreamble,
4493
+ newBoundary.contentState,
4399
4494
  task.abortSet,
4400
4495
  keyPath,
4401
4496
  task.formatContext,
@@ -4407,8 +4502,9 @@ function renderElement(request, task, keyPath, type, props, ref) {
4407
4502
  pushComponentStack(task);
4408
4503
  request.pingedTasks.push(task);
4409
4504
  } else {
4410
- task.blockedBoundary = propName;
4411
- task.hoistableState = propName.contentState;
4505
+ task.blockedBoundary = newBoundary;
4506
+ task.blockedPreamble = newBoundary.contentPreamble;
4507
+ task.hoistableState = newBoundary.contentState;
4412
4508
  task.blockedSegment = contentRootSegment;
4413
4509
  task.keyPath = keyPath;
4414
4510
  contentRootSegment.status = 6;
@@ -4419,14 +4515,17 @@ function renderElement(request, task, keyPath, type, props, ref) {
4419
4515
  contentRootSegment.textEmbedded &&
4420
4516
  contentRootSegment.chunks.push(textSeparator),
4421
4517
  (contentRootSegment.status = 1),
4422
- queueCompletedSegment(propName, contentRootSegment),
4423
- 0 === propName.pendingTasks && 0 === propName.status)
4518
+ queueCompletedSegment(newBoundary, contentRootSegment),
4519
+ 0 === newBoundary.pendingTasks && 0 === newBoundary.status)
4424
4520
  ) {
4425
- propName.status = 1;
4521
+ newBoundary.status = 1;
4522
+ 0 === request.pendingRootTasks &&
4523
+ task.blockedPreamble &&
4524
+ preparePreamble(request);
4426
4525
  break a;
4427
4526
  }
4428
4527
  } catch (thrownValue$28) {
4429
- (propName.status = 4),
4528
+ (newBoundary.status = 4),
4430
4529
  12 === request.status
4431
4530
  ? ((contentRootSegment.status = 3),
4432
4531
  (newProps = request.fatalError))
@@ -4438,22 +4537,24 @@ function renderElement(request, task, keyPath, type, props, ref) {
4438
4537
  newProps,
4439
4538
  defaultProps
4440
4539
  )),
4441
- (propName.errorDigest = initialState),
4442
- untrackBoundary(request, propName);
4540
+ (newBoundary.errorDigest = initialState),
4541
+ untrackBoundary(request, newBoundary);
4443
4542
  } finally {
4444
4543
  (task.blockedBoundary = parentBoundary),
4544
+ (task.blockedPreamble = ref),
4445
4545
  (task.hoistableState = parentHoistableState),
4446
- (task.blockedSegment = ref),
4546
+ (task.blockedSegment = propName$33),
4447
4547
  (task.keyPath = type);
4448
4548
  }
4449
4549
  task = createRenderTask(
4450
4550
  request,
4451
4551
  null,
4452
- propName$33,
4552
+ propName,
4453
4553
  -1,
4454
4554
  parentBoundary,
4455
4555
  boundarySegment,
4456
- propName.fallbackState,
4556
+ newBoundary.fallbackPreamble,
4557
+ newBoundary.fallbackState,
4457
4558
  fallbackAbortSet,
4458
4559
  [keyPath[0], "Suspense Fallback", keyPath[2]],
4459
4560
  task.formatContext,
@@ -4472,9 +4573,9 @@ function renderElement(request, task, keyPath, type, props, ref) {
4472
4573
  switch (type.$$typeof) {
4473
4574
  case REACT_FORWARD_REF_TYPE:
4474
4575
  if ("ref" in props)
4475
- for (boundarySegment in ((newProps = {}), props))
4476
- "ref" !== boundarySegment &&
4477
- (newProps[boundarySegment] = props[boundarySegment]);
4576
+ for (newBoundary in ((newProps = {}), props))
4577
+ "ref" !== newBoundary &&
4578
+ (newProps[newBoundary] = props[newBoundary]);
4478
4579
  else newProps = props;
4479
4580
  type = renderWithHooks(
4480
4581
  request,
@@ -4679,17 +4780,27 @@ function retryNode(request, task) {
4679
4780
  previousReplaySet = task.replay,
4680
4781
  parentBoundary = task.blockedBoundary,
4681
4782
  parentHoistableState = task.hoistableState,
4682
- content = props.children;
4683
- props = props.fallback;
4684
- var fallbackAbortSet = new Set(),
4685
- resumedBoundary = createSuspenseBoundary(
4686
- request,
4687
- fallbackAbortSet
4688
- );
4689
- resumedBoundary.parentFlushed = !0;
4690
- resumedBoundary.rootSegmentID = type;
4691
- task.blockedBoundary = resumedBoundary;
4692
- task.hoistableState = resumedBoundary.contentState;
4783
+ content = props.children,
4784
+ fallback = props.fallback,
4785
+ fallbackAbortSet = new Set();
4786
+ props =
4787
+ 2 > task.formatContext.insertionMode
4788
+ ? createSuspenseBoundary(
4789
+ request,
4790
+ fallbackAbortSet,
4791
+ createPreambleState(),
4792
+ createPreambleState()
4793
+ )
4794
+ : createSuspenseBoundary(
4795
+ request,
4796
+ fallbackAbortSet,
4797
+ null,
4798
+ null
4799
+ );
4800
+ props.parentFlushed = !0;
4801
+ props.rootSegmentID = type;
4802
+ task.blockedBoundary = props;
4803
+ task.hoistableState = props.contentState;
4693
4804
  task.keyPath = key;
4694
4805
  task.replay = {
4695
4806
  nodes: ref,
@@ -4706,27 +4817,22 @@ function retryNode(request, task) {
4706
4817
  "Couldn't find all resumable slots by key/index during replaying. The tree doesn't match so React will fallback to client rendering."
4707
4818
  );
4708
4819
  task.replay.pendingTasks--;
4709
- if (
4710
- 0 === resumedBoundary.pendingTasks &&
4711
- 0 === resumedBoundary.status
4712
- ) {
4713
- resumedBoundary.status = 1;
4714
- request.completedBoundaries.push(resumedBoundary);
4820
+ if (0 === props.pendingTasks && 0 === props.status) {
4821
+ props.status = 1;
4822
+ request.completedBoundaries.push(props);
4715
4823
  break b;
4716
4824
  }
4717
4825
  } catch (error) {
4718
- (resumedBoundary.status = 4),
4826
+ (props.status = 4),
4719
4827
  (childNodes = getThrownInfo(task.componentStack)),
4720
4828
  (replay = logRecoverableError(
4721
4829
  request,
4722
4830
  error,
4723
4831
  childNodes
4724
4832
  )),
4725
- (resumedBoundary.errorDigest = replay),
4833
+ (props.errorDigest = replay),
4726
4834
  task.replay.pendingTasks--,
4727
- request.clientRenderedBoundaries.push(
4728
- resumedBoundary
4729
- );
4835
+ request.clientRenderedBoundaries.push(props);
4730
4836
  } finally {
4731
4837
  (task.blockedBoundary = parentBoundary),
4732
4838
  (task.hoistableState = parentHoistableState),
@@ -4741,10 +4847,10 @@ function retryNode(request, task) {
4741
4847
  slots: node$jscomp$0,
4742
4848
  pendingTasks: 0
4743
4849
  },
4744
- props,
4850
+ fallback,
4745
4851
  -1,
4746
4852
  parentBoundary,
4747
- resumedBoundary.fallbackState,
4853
+ props.fallbackState,
4748
4854
  fallbackAbortSet,
4749
4855
  [key[0], "Suspense Fallback", key[2]],
4750
4856
  task.formatContext,
@@ -4960,6 +5066,7 @@ function spawnNewSuspendedRenderTask(request, task, thenableState) {
4960
5066
  task.childIndex,
4961
5067
  task.blockedBoundary,
4962
5068
  newSegment,
5069
+ task.blockedPreamble,
4963
5070
  task.hoistableState,
4964
5071
  task.abortSet,
4965
5072
  task.keyPath,
@@ -5093,7 +5200,12 @@ function abortRemainingReplayNodes(
5093
5200
  node = node[5];
5094
5201
  var request = request$jscomp$0,
5095
5202
  errorDigest = errorDigest$jscomp$0,
5096
- resumedBoundary = createSuspenseBoundary(request, new Set());
5203
+ resumedBoundary = createSuspenseBoundary(
5204
+ request,
5205
+ new Set(),
5206
+ null,
5207
+ null
5208
+ );
5097
5209
  resumedBoundary.parentFlushed = !0;
5098
5210
  resumedBoundary.rootSegmentID = node;
5099
5211
  resumedBoundary.status = 4;
@@ -5227,6 +5339,7 @@ function safelyEmitEarlyPreloads(request, shellComplete) {
5227
5339
  }
5228
5340
  function completeShell(request) {
5229
5341
  null === request.trackedPostpones && safelyEmitEarlyPreloads(request, !0);
5342
+ null === request.trackedPostpones && preparePreamble(request);
5230
5343
  request.onShellError = noop;
5231
5344
  request = request.onShellReady;
5232
5345
  request();
@@ -5239,6 +5352,7 @@ function completeAll(request) {
5239
5352
  : null === request.completedRootSegment ||
5240
5353
  5 !== request.completedRootSegment.status
5241
5354
  );
5355
+ preparePreamble(request);
5242
5356
  request = request.onAllReady;
5243
5357
  request();
5244
5358
  }
@@ -5279,7 +5393,11 @@ function finishedTask(request, boundary, segment) {
5279
5393
  request.completedBoundaries.push(boundary),
5280
5394
  1 === boundary.status &&
5281
5395
  (boundary.fallbackAbortableTasks.forEach(abortTaskSoft, request),
5282
- boundary.fallbackAbortableTasks.clear()))
5396
+ boundary.fallbackAbortableTasks.clear(),
5397
+ 0 === request.pendingRootTasks &&
5398
+ null === request.trackedPostpones &&
5399
+ null !== boundary.contentPreamble &&
5400
+ preparePreamble(request)))
5283
5401
  : null !== segment &&
5284
5402
  segment.parentFlushed &&
5285
5403
  1 === segment.status &&
@@ -5436,9 +5554,11 @@ function performWork(request$jscomp$2) {
5436
5554
  (boundary$jscomp$0.errorDigest = request$jscomp$0),
5437
5555
  untrackBoundary(request, boundary$jscomp$0),
5438
5556
  boundary$jscomp$0.parentFlushed &&
5439
- request.clientRenderedBoundaries.push(
5440
- boundary$jscomp$0
5441
- )));
5557
+ request.clientRenderedBoundaries.push(boundary$jscomp$0),
5558
+ 0 === request.pendingRootTasks &&
5559
+ null === request.trackedPostpones &&
5560
+ null !== boundary$jscomp$0.contentPreamble &&
5561
+ preparePreamble(request)));
5442
5562
  request.allPendingTasks--;
5443
5563
  0 === request.allPendingTasks && completeAll(request);
5444
5564
  }
@@ -5461,6 +5581,85 @@ function performWork(request$jscomp$2) {
5461
5581
  }
5462
5582
  }
5463
5583
  }
5584
+ function preparePreambleFromSubtree(
5585
+ request,
5586
+ segment,
5587
+ collectedPreambleSegments
5588
+ ) {
5589
+ segment.preambleChildren.length &&
5590
+ collectedPreambleSegments.push(segment.preambleChildren);
5591
+ for (var pendingPreambles = !1, i = 0; i < segment.children.length; i++)
5592
+ pendingPreambles =
5593
+ preparePreambleFromSegment(
5594
+ request,
5595
+ segment.children[i],
5596
+ collectedPreambleSegments
5597
+ ) || pendingPreambles;
5598
+ return pendingPreambles;
5599
+ }
5600
+ function preparePreambleFromSegment(
5601
+ request,
5602
+ segment,
5603
+ collectedPreambleSegments
5604
+ ) {
5605
+ var boundary = segment.boundary;
5606
+ if (null === boundary)
5607
+ return preparePreambleFromSubtree(
5608
+ request,
5609
+ segment,
5610
+ collectedPreambleSegments
5611
+ );
5612
+ var preamble = boundary.contentPreamble,
5613
+ fallbackPreamble = boundary.fallbackPreamble;
5614
+ if (null === preamble || null === fallbackPreamble) return !1;
5615
+ switch (boundary.status) {
5616
+ case 1:
5617
+ hoistPreambleState(request.renderState, preamble);
5618
+ segment = boundary.completedSegments[0];
5619
+ if (!segment)
5620
+ throw Error(
5621
+ "A previously unvisited boundary must have exactly one root segment. This is a bug in React."
5622
+ );
5623
+ return preparePreambleFromSubtree(
5624
+ request,
5625
+ segment,
5626
+ collectedPreambleSegments
5627
+ );
5628
+ case 5:
5629
+ if (null !== request.trackedPostpones) return !0;
5630
+ case 4:
5631
+ if (1 === segment.status)
5632
+ return (
5633
+ hoistPreambleState(request.renderState, fallbackPreamble),
5634
+ preparePreambleFromSubtree(
5635
+ request,
5636
+ segment,
5637
+ collectedPreambleSegments
5638
+ )
5639
+ );
5640
+ default:
5641
+ return !0;
5642
+ }
5643
+ }
5644
+ function preparePreamble(request) {
5645
+ if (
5646
+ request.completedRootSegment &&
5647
+ null === request.completedPreambleSegments
5648
+ ) {
5649
+ var collectedPreambleSegments = [],
5650
+ hasPendingPreambles = preparePreambleFromSegment(
5651
+ request,
5652
+ request.completedRootSegment,
5653
+ collectedPreambleSegments
5654
+ ),
5655
+ preamble = request.renderState.preamble;
5656
+ if (
5657
+ !1 === hasPendingPreambles ||
5658
+ (preamble.headChunks && preamble.bodyChunks)
5659
+ )
5660
+ request.completedPreambleSegments = collectedPreambleSegments;
5661
+ }
5662
+ }
5464
5663
  function flushSubtree(request, destination, segment, hoistableState) {
5465
5664
  segment.parentFlushed = !0;
5466
5665
  switch (segment.status) {
@@ -5664,9 +5863,12 @@ function flushCompletedQueues(request, destination) {
5664
5863
  completedRootSegment = request.completedRootSegment;
5665
5864
  if (null !== completedRootSegment) {
5666
5865
  if (5 === completedRootSegment.status) return;
5866
+ var completedPreambleSegments = request.completedPreambleSegments;
5867
+ if (null === completedPreambleSegments) return;
5667
5868
  var renderState = request.renderState,
5668
- htmlChunks = renderState.htmlChunks,
5669
- headChunks = renderState.headChunks,
5869
+ preamble = renderState.preamble,
5870
+ htmlChunks = preamble.htmlChunks,
5871
+ headChunks = preamble.headChunks,
5670
5872
  i$jscomp$0;
5671
5873
  if (htmlChunks) {
5672
5874
  for (i$jscomp$0 = 0; i$jscomp$0 < htmlChunks.length; i$jscomp$0++)
@@ -5707,10 +5909,27 @@ function flushCompletedQueues(request, destination) {
5707
5909
  var hoistableChunks = renderState.hoistableChunks;
5708
5910
  for (i$jscomp$0 = 0; i$jscomp$0 < hoistableChunks.length; i$jscomp$0++)
5709
5911
  writeChunk(destination, hoistableChunks[i$jscomp$0]);
5710
- hoistableChunks.length = 0;
5711
- htmlChunks &&
5712
- null === headChunks &&
5912
+ for (
5913
+ renderState = hoistableChunks.length = 0;
5914
+ renderState < completedPreambleSegments.length;
5915
+ renderState++
5916
+ ) {
5917
+ var segments = completedPreambleSegments[renderState];
5918
+ for (preamble = 0; preamble < segments.length; preamble++)
5919
+ flushSegment(request, destination, segments[preamble], null);
5920
+ }
5921
+ var preamble$jscomp$0 = request.renderState.preamble,
5922
+ headChunks$jscomp$0 = preamble$jscomp$0.headChunks;
5923
+ (preamble$jscomp$0.htmlChunks || headChunks$jscomp$0) &&
5713
5924
  writeChunk(destination, endChunkForTag("head"));
5925
+ var bodyChunks = preamble$jscomp$0.bodyChunks;
5926
+ if (bodyChunks)
5927
+ for (
5928
+ completedPreambleSegments = 0;
5929
+ completedPreambleSegments < bodyChunks.length;
5930
+ completedPreambleSegments++
5931
+ )
5932
+ writeChunk(destination, bodyChunks[completedPreambleSegments]);
5714
5933
  flushSegment(request, destination, completedRootSegment, null);
5715
5934
  request.completedRootSegment = null;
5716
5935
  writeBootstrap(destination, request.renderState);
@@ -5938,11 +6157,11 @@ function abort(request, reason) {
5938
6157
  }
5939
6158
  function ensureCorrectIsomorphicReactVersion() {
5940
6159
  var isomorphicReactPackageVersion = React.version;
5941
- if ("19.1.0-canary-d46b04a2-20250117" !== isomorphicReactPackageVersion)
6160
+ if ("19.1.0-canary-9b62ee71-20250122" !== isomorphicReactPackageVersion)
5942
6161
  throw Error(
5943
6162
  'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
5944
6163
  (isomorphicReactPackageVersion +
5945
- "\n - react-dom: 19.1.0-canary-d46b04a2-20250117\nLearn more: https://react.dev/warnings/version-mismatch")
6164
+ "\n - react-dom: 19.1.0-canary-9b62ee71-20250122\nLearn more: https://react.dev/warnings/version-mismatch")
5946
6165
  );
5947
6166
  }
5948
6167
  ensureCorrectIsomorphicReactVersion();
@@ -6091,4 +6310,4 @@ exports.renderToPipeableStream = function (children, options) {
6091
6310
  }
6092
6311
  };
6093
6312
  };
6094
- exports.version = "19.1.0-canary-d46b04a2-20250117";
6313
+ exports.version = "19.1.0-canary-9b62ee71-20250122";