diff --git a/dist/dom/features/suspense/full.js b/dist/dom/features/suspense/full.js index 1449439b96862749a1d5b3df098e21791274e5df..9e2ee8c11350b92c441ad5dfb83c2434cc17daa9 100644 --- a/dist/dom/features/suspense/full.js +++ b/dist/dom/features/suspense/full.js @@ -122,6 +122,15 @@ function renderSuspense(fiber) { const checkpoint2 = checkpointCommit(fiber); const wasHydrating = root.h; root.h = true; + // Patched (intlayer): a child suspending while this dehydrated boundary + // re-hydrates must reach the catch below as its thenable. Without a + // handler, realHandleSuspended throws a RenderSuspenseCapture that drops + // the thenable, the boundary is rescheduled synchronously and flushPending + // spins until its 50-pass guard throws. + const prevHydrationHandler = suspendHandler; + suspendHandler = (thenable) => { + throw thenable; + }; try { hydrateSuspenseBoundary(fiber, props, [state.b.data === "$!" ? 2 : 0, 0, state.b, state.e]); } catch (error) { @@ -131,6 +140,7 @@ function renderSuspense(fiber) { fiber.b = state; retryHydration(fiber, error); } finally { + suspendHandler = prevHydrationHandler; root.h = wasHydrating; } return; diff --git a/dist/dom/features/lazy/full.js b/dist/dom/features/lazy/full.js index d7c090b10a48aaeb6336576325166bbc5d8871f6..e4ffdcd58a98ffaaa22f52524015af78b60bb487 100644 --- a/dist/dom/features/lazy/full.js +++ b/dist/dom/features/lazy/full.js @@ -10,6 +10,9 @@ function renderLazy(fiber) { resolved = resolveRefreshType(resolved); } catch (thenable) { if (isThenable(thenable)) { + // Patched (intlayer): renderNode keeps the update flag on lazy fibers + // for the resolved type; nothing consumes it while suspended. + fiber.g = false; if (deferHydration(fiber, thenable)) return; handleSuspended(fiber, thenable); diff --git a/dist/dom/reconcile.js b/dist/dom/reconcile.js index c91b3da5752d5f8f5b482dcb2a040ac3af031381..c22949076fa38a1aabaa737b88583a85d7b83a00 100644 --- a/dist/dom/reconcile.js +++ b/dist/dom/reconcile.js @@ -14,7 +14,7 @@ import { deferHydration } from "./features/hydration/index.js"; import { m as markTransitionUpdate, d as deferTransition, c as cancelTransitions, l as deferTransitionLayout, p as deferTransitionPassive } from "./features/view-transition/index.js"; import { clearAttributes, clearHostContainer, documentMetadataParent, documentSingleton, DOCUMENT_HEAD_TAGS } from "./document-metadata.js"; import { acquireResource } from "./resources.js"; -import { a as transitionRender, p as hasTransition, t as flushTransitions, c as cancelPendingTransitions, s as scheduleTransitionRoot } from "./features/suspense-runtime/index.js"; +import { a as transitionRender, p as hasTransition, t as flushTransitions, c as cancelPendingTransitions, s as scheduleTransitionRoot, w as prewarmingTransition } from "./features/suspense-runtime/index.js"; import { commitFragmentRef, placeFragmentCommits, updateFragmentHost, refreshFragmentInstances } from "./features/fragment-refs/index.js"; import { isObject } from "../core/functions.js"; import { createFiber, REACT_ELEMENT_TYPE, REACT_LEGACY_ELEMENT_TYPE, REACT_FRAGMENT_TYPE } from "../core/index.js"; @@ -920,7 +920,11 @@ function renderNode(fiber) { })(fiber); fiber.type = resolveRefreshType(fiber.type); } - if (fiber.t !== 9) + // Patched (intlayer): a lazy fiber delegates to its resolved type on this + // same fiber, so clearing the update flag here made a lazy memo component + // bail out on equal props and drop its own pending update (e.g. a store + // read by both the component and an ancestor). Memo and lazy keep it. + if (fiber.t !== 9 && fiber.t !== 10) fiber.g = false; fiber.r ||= currentRoot || findRoot2(fiber); if (fiber.r?.sp && fiber.p?.ld && fiber.m === null) @@ -1126,8 +1130,11 @@ function handleSuspended(fiber, thenable) { defaultHandleSuspended(fiber, thenable); return; } - if (transitionRender) + if (transitionRender) { + if (prewarmingTransition) + return; throw thenable; + } CAPABILITIES.h(fiber, thenable); } function scheduleUpdate(fiber) { diff --git a/dist/dom/transitions.js b/dist/dom/transitions.js index 520687f58d6608841b2a6c33cff1c29151594392..a4bd74ddc0b6bb4672f7490facc4c011608ff0bf 100644 --- a/dist/dom/transitions.js +++ b/dist/dom/transitions.js @@ -5,6 +5,7 @@ import { checkpointCommit, rewindCommit, queueCommitEffects } from "./commit.js" import { ReactSharedInternals } from "../react/shared-internals.js"; import { transitionScope } from "../react/hooks.js"; let a = false; +let w = false; const p = (fiber) => !!fiber.r?.tr?.has(fiber); function q(hook, fiber, action) { const scope = ReactSharedInternals.T && ReactSharedInternals.B; @@ -64,6 +65,8 @@ function t(root, render) { scope.n?.(scope); if (pending.w !== error) { pending.w = error; + if (!root.h) + prewarm(root, render, fibers, pending.u); const retry = () => transitionScope(() => { for (const fiber of pending) scheduleUpdate(fiber); @@ -74,6 +77,17 @@ function t(root, render) { a = false; } } +function prewarm(root, render, fibers, update) { + const checkpoint = checkpointCommit(root.r); + w = true; + try { + render(root, fibers, update); + } catch { + } finally { + w = false; + rewindCommit(checkpoint); + } +} function complete(work) { for (const scope of work) { scope.v--; @@ -143,6 +157,7 @@ export { r, s, t, - v + v, + w }; //# sourceMappingURL=transitions.js.map diff --git a/dist/dom/features/suspense-runtime/stub.js b/dist/dom/features/suspense-runtime/stub.js index 67521879f7a646839833d90f691b9eea842ea0d3..ef384eb20d0c204016a4c7ed1edfe3ce20b0cc80 100644 --- a/dist/dom/features/suspense-runtime/stub.js +++ b/dist/dom/features/suspense-runtime/stub.js @@ -1,4 +1,4 @@ -const a = void 0, p = void 0, q = void 0, r = void 0, t = void 0, v = void 0, c = void 0, s = void 0; +const a = void 0, p = void 0, q = void 0, r = void 0, t = void 0, v = void 0, c = void 0, s = void 0, w = void 0; export { a, c, @@ -7,6 +7,7 @@ export { r, s, t, - v + v, + w }; //# sourceMappingURL=stub.js.map diff --git a/dist/dom/features/suspense-hydration/full.js b/dist/dom/features/suspense-hydration/full.js index 8343e11a051e4cd1f550a412a37d6b0df32b82b5..4660d700ccc6308625cf12ca604d978f383ec607 100644 --- a/dist/dom/features/suspense-hydration/full.js +++ b/dist/dom/features/suspense-hydration/full.js @@ -114,7 +114,11 @@ function hydrateSuspenseBoundary(fiber, props, boundary, reveal) { }); throw e; } else - recoverBoundaryHydration(fiber, props.children, parent, startMark, endMark); + // Patched (intlayer): client-render the mismatched boundary through + // renderSuspense, like a "$!" boundary. A plain reconcile has no + // suspend handler, so a child suspending there escaped hydration as a + // RenderSuspenseCapture and left the boundary empty. + recoverBoundaryHydration(fiber, props.children, parent, startMark, endMark, true); } finally { clearHydrationCursor(fiber); }