This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+10 -8
View File
@@ -4,7 +4,7 @@ import { HtmlEscapedCallbackPhase, resolveCallback } from "../utils/html.js";
import { JSXNode } from "./base.js";
import { childrenToString } from "./components.js";
import { DOM_RENDERER, DOM_STASH } from "./constants.js";
import { createContext, useContext } from "./context.js";
import { captureRenderContext, createContext, useContext } from "./context.js";
import { Suspense as SuspenseDomRenderer } from "./dom/components.js";
import { buildDataStack } from "./dom/render.js";
var StreamingContext = createContext(null);
@@ -19,9 +19,8 @@ var Suspense = async ({
const nonce = useContext(StreamingContext)?.scriptNonce;
let resArray = [];
const stackNode = { [DOM_STASH]: [0, []] };
const popNodeStack = (value) => {
const popNodeStack = () => {
buildDataStack.pop();
return value;
};
try {
stackNode[DOM_STASH][0] = 0;
@@ -31,12 +30,15 @@ var Suspense = async ({
);
} catch (e) {
if (e instanceof Promise) {
const resume = captureRenderContext();
resArray = [
e.then(() => {
stackNode[DOM_STASH][0] = 0;
buildDataStack.push([[], stackNode]);
return childrenToString(children).then(popNodeStack);
})
e.then(
() => resume(() => {
stackNode[DOM_STASH][0] = 0;
buildDataStack.push([[], stackNode]);
return childrenToString(children).finally(popNodeStack);
})
)
];
} else {
throw e;