@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
69
69
return self;
70
70
}
71
71
72
- var ReactVersion = "18.3.0-www-classic-7d98bb40 ";
72
+ var ReactVersion = "18.3.0-www-classic-dfeb256e ";
73
73
74
74
var LegacyRoot = 0;
75
75
var ConcurrentRoot = 1;
@@ -2521,33 +2521,44 @@ function lanesToEventPriority(lanes) {
2521
2521
2522
2522
// Renderers that don't support hydration
2523
2523
// can re-export everything from this module.
2524
- function shim$1 () {
2524
+ function shim$2 () {
2525
2525
throw new Error(
2526
2526
"The current renderer does not support hydration. " +
2527
2527
"This error is likely caused by a bug in React. " +
2528
2528
"Please file an issue."
2529
2529
);
2530
2530
} // Hydration (when unsupported)
2531
- var isSuspenseInstancePending = shim$1 ;
2532
- var isSuspenseInstanceFallback = shim$1 ;
2533
- var getSuspenseInstanceFallbackErrorDetails = shim$1 ;
2534
- var registerSuspenseInstanceRetry = shim$1 ;
2535
- var clearSuspenseBoundary = shim$1 ;
2536
- var clearSuspenseBoundaryFromContainer = shim$1 ;
2537
- var errorHydratingContainer = shim$1 ;
2531
+ var isSuspenseInstancePending = shim$2 ;
2532
+ var isSuspenseInstanceFallback = shim$2 ;
2533
+ var getSuspenseInstanceFallbackErrorDetails = shim$2 ;
2534
+ var registerSuspenseInstanceRetry = shim$2 ;
2535
+ var clearSuspenseBoundary = shim$2 ;
2536
+ var clearSuspenseBoundaryFromContainer = shim$2 ;
2537
+ var errorHydratingContainer = shim$2 ;
2538
2538
2539
2539
// Renderers that don't support React Scopes
2540
2540
// can re-export everything from this module.
2541
- function shim() {
2541
+ function shim$1 () {
2542
2542
throw new Error(
2543
2543
"The current renderer does not support React Scopes. " +
2544
2544
"This error is likely caused by a bug in React. " +
2545
2545
"Please file an issue."
2546
2546
);
2547
2547
} // React Scopes (when unsupported)
2548
2548
2549
- var prepareScopeUpdate = shim;
2550
- var getInstanceFromScope = shim;
2549
+ var prepareScopeUpdate = shim$1;
2550
+ var getInstanceFromScope = shim$1;
2551
+
2552
+ // Renderers that don't support hydration
2553
+ // can re-export everything from this module.
2554
+ function shim() {
2555
+ throw new Error(
2556
+ "The current renderer does not support Resources. " +
2557
+ "This error is likely caused by a bug in React. " +
2558
+ "Please file an issue."
2559
+ );
2560
+ } // Resources (when unsupported)
2561
+ var suspendResource = shim;
2551
2562
2552
2563
var pooledTransform = new Transform();
2553
2564
var NO_CONTEXT = {};
@@ -2923,6 +2934,9 @@ function unhideTextInstance(textInstance, text) {
2923
2934
function getInstanceFromNode(node) {
2924
2935
throw new Error("Not implemented.");
2925
2936
}
2937
+ function maySuspendCommit(type, props) {
2938
+ return false;
2939
+ }
2926
2940
function preloadInstance(type, props) {
2927
2941
// Return true to indicate it's already loaded
2928
2942
return true;
@@ -5576,6 +5590,13 @@ function trackUsedThenable(thenableState, thenable, index) {
5576
5590
}
5577
5591
}
5578
5592
}
5593
+ function suspendCommit() {
5594
+ // This extra indirection only exists so it can handle passing
5595
+ // noopSuspenseyCommitThenable through to throwException.
5596
+ // TODO: Factor the thenable check out of throwException
5597
+ suspendedThenable = noopSuspenseyCommitThenable;
5598
+ throw SuspenseyCommitException;
5599
+ } // This is used to track the actual thenable that suspended so it can be
5579
5600
// passed to the rest of the Suspense implementation — which, for historical
5580
5601
// reasons, expects to receive a thenable.
5581
5602
@@ -17687,16 +17708,28 @@ function preloadInstanceAndSuspendIfNeeded(
17687
17708
props,
17688
17709
renderLanes
17689
17710
) {
17690
- // Ask the renderer if this instance should suspend the commit.
17691
- {
17692
- // If this flag was set previously, we can remove it. The flag represents
17693
- // whether this particular set of props might ever need to suspend. The
17694
- // safest thing to do is for maySuspendCommit to always return true, but
17695
- // if the renderer is reasonably confident that the underlying resource
17696
- // won't be evicted, it can return false as a performance optimization.
17697
- workInProgress.flags &= ~SuspenseyCommit;
17698
- return;
17699
- } // Mark this fiber with a flag. We use this right before the commit phase to
17711
+ workInProgress.flags |= SuspenseyCommit; // Check if we're rendering at a "non-urgent" priority. This is the same
17712
+ // check that `useDeferredValue` does to determine whether it needs to
17713
+ // defer. This is partly for gradual adoption purposes (i.e. shouldn't start
17714
+ // suspending until you opt in with startTransition or Suspense) but it
17715
+ // also happens to be the desired behavior for the concrete use cases we've
17716
+ // thought of so far, like CSS loading, fonts, images, etc.
17717
+ // TODO: We may decide to expose a way to force a fallback even during a
17718
+ // sync update.
17719
+
17720
+ if (!includesOnlyNonUrgentLanes(renderLanes));
17721
+ else {
17722
+ // Preload the instance
17723
+ var isReady = preloadInstance();
17724
+
17725
+ if (!isReady) {
17726
+ if (shouldRemainOnPreviousScreen());
17727
+ else {
17728
+ // Trigger a fallback rather than block the render.
17729
+ suspendCommit();
17730
+ }
17731
+ }
17732
+ }
17700
17733
}
17701
17734
17702
17735
function scheduleRetryEffect(workInProgress, retryQueue) {
@@ -18129,6 +18162,8 @@ function completeWork(current, workInProgress, renderLanes) {
18129
18162
popHostContext(workInProgress);
18130
18163
var _type = workInProgress.type;
18131
18164
18165
+ var _maySuspend = maySuspendCommit();
18166
+
18132
18167
if (current !== null && workInProgress.stateNode != null) {
18133
18168
updateHostComponent(current, workInProgress, _type, newProps);
18134
18169
@@ -18183,7 +18218,17 @@ function completeWork(current, workInProgress, renderLanes) {
18183
18218
// will resume rendering as if the work-in-progress completed. So it must
18184
18219
// fully complete.
18185
18220
18186
- preloadInstanceAndSuspendIfNeeded(workInProgress);
18221
+ if (_maySuspend) {
18222
+ preloadInstanceAndSuspendIfNeeded(
18223
+ workInProgress,
18224
+ _type,
18225
+ newProps,
18226
+ renderLanes
18227
+ );
18228
+ } else {
18229
+ workInProgress.flags &= ~SuspenseyCommit;
18230
+ }
18231
+
18187
18232
return null;
18188
18233
}
18189
18234
@@ -22559,6 +22604,50 @@ function commitPassiveUnmountEffects(finishedWork) {
22559
22604
commitPassiveUnmountOnFiber(finishedWork);
22560
22605
resetCurrentFiber();
22561
22606
}
22607
+ function accumulateSuspenseyCommit(finishedWork) {
22608
+ accumulateSuspenseyCommitOnFiber(finishedWork);
22609
+ }
22610
+
22611
+ function recursivelyAccumulateSuspenseyCommit(parentFiber) {
22612
+ if (parentFiber.subtreeFlags & SuspenseyCommit) {
22613
+ var child = parentFiber.child;
22614
+
22615
+ while (child !== null) {
22616
+ accumulateSuspenseyCommitOnFiber(child);
22617
+ child = child.sibling;
22618
+ }
22619
+ }
22620
+ }
22621
+
22622
+ function accumulateSuspenseyCommitOnFiber(fiber) {
22623
+ switch (fiber.tag) {
22624
+ case HostHoistable: {
22625
+ recursivelyAccumulateSuspenseyCommit(fiber);
22626
+
22627
+ if (fiber.flags & SuspenseyCommit) {
22628
+ if (fiber.memoizedState !== null) {
22629
+ suspendResource();
22630
+ }
22631
+ }
22632
+
22633
+ break;
22634
+ }
22635
+
22636
+ case HostComponent: {
22637
+ recursivelyAccumulateSuspenseyCommit(fiber);
22638
+
22639
+ break;
22640
+ }
22641
+
22642
+ case HostRoot:
22643
+ case HostPortal:
22644
+ // eslint-disable-next-line-no-fallthrough
22645
+
22646
+ default: {
22647
+ recursivelyAccumulateSuspenseyCommit(fiber);
22648
+ }
22649
+ }
22650
+ }
22562
22651
22563
22652
function detachAlternateSiblings(parentFiber) {
22564
22653
// A fiber was deleted from this parent fiber, but it's still part of the
@@ -24161,6 +24250,11 @@ function commitRootWhenReady(
24161
24250
lanes
24162
24251
) {
24163
24252
if (includesOnlyNonUrgentLanes(lanes)) {
24253
+ // the suspensey resources. The renderer is responsible for accumulating
24254
+ // all the load events. This all happens in a single synchronous
24255
+ // transaction, so it track state in its own module scope.
24256
+
24257
+ accumulateSuspenseyCommit(finishedWork); // At the end, ask the renderer if it's ready to commit, or if we should
24164
24258
// suspend. If it's not ready, it will return a callback to subscribe to
24165
24259
// a ready event.
24166
24260
0 commit comments