full site update
This commit is contained in:
109
node_modules/astro/dist/runtime/server/render/any.js
generated
vendored
109
node_modules/astro/dist/runtime/server/render/any.js
generated
vendored
@@ -3,44 +3,93 @@ import { isPromise } from "../util.js";
|
||||
import { isAstroComponentInstance, isRenderTemplateResult } from "./astro/index.js";
|
||||
import { isRenderInstance } from "./common.js";
|
||||
import { SlotString } from "./slot.js";
|
||||
import { renderToBufferDestination } from "./util.js";
|
||||
async function renderChild(destination, child) {
|
||||
import { createBufferedRenderer } from "./util.js";
|
||||
function renderChild(destination, child) {
|
||||
if (isPromise(child)) {
|
||||
child = await child;
|
||||
return child.then((x) => renderChild(destination, x));
|
||||
}
|
||||
if (child instanceof SlotString) {
|
||||
destination.write(child);
|
||||
} else if (isHTMLString(child)) {
|
||||
return;
|
||||
}
|
||||
if (isHTMLString(child)) {
|
||||
destination.write(child);
|
||||
} else if (Array.isArray(child)) {
|
||||
const childRenders = child.map((c) => {
|
||||
return renderToBufferDestination((bufferDestination) => {
|
||||
return renderChild(bufferDestination, c);
|
||||
});
|
||||
});
|
||||
for (const childRender of childRenders) {
|
||||
if (!childRender) continue;
|
||||
await childRender.renderToFinalDestination(destination);
|
||||
}
|
||||
} else if (typeof child === "function") {
|
||||
await renderChild(destination, child());
|
||||
} else if (typeof child === "string") {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(child)) {
|
||||
return renderArray(destination, child);
|
||||
}
|
||||
if (typeof child === "function") {
|
||||
return renderChild(destination, child());
|
||||
}
|
||||
if (!child && child !== 0) {
|
||||
return;
|
||||
}
|
||||
if (typeof child === "string") {
|
||||
destination.write(markHTMLString(escapeHTML(child)));
|
||||
} else if (!child && child !== 0) {
|
||||
} else if (isRenderInstance(child)) {
|
||||
await child.render(destination);
|
||||
} else if (isRenderTemplateResult(child)) {
|
||||
await child.render(destination);
|
||||
} else if (isAstroComponentInstance(child)) {
|
||||
await child.render(destination);
|
||||
} else if (ArrayBuffer.isView(child)) {
|
||||
return;
|
||||
}
|
||||
if (isRenderInstance(child)) {
|
||||
return child.render(destination);
|
||||
}
|
||||
if (isRenderTemplateResult(child)) {
|
||||
return child.render(destination);
|
||||
}
|
||||
if (isAstroComponentInstance(child)) {
|
||||
return child.render(destination);
|
||||
}
|
||||
if (ArrayBuffer.isView(child)) {
|
||||
destination.write(child);
|
||||
} else if (typeof child === "object" && (Symbol.asyncIterator in child || Symbol.iterator in child)) {
|
||||
for await (const value of child) {
|
||||
await renderChild(destination, value);
|
||||
return;
|
||||
}
|
||||
if (typeof child === "object" && (Symbol.asyncIterator in child || Symbol.iterator in child)) {
|
||||
if (Symbol.asyncIterator in child) {
|
||||
return renderAsyncIterable(destination, child);
|
||||
}
|
||||
} else {
|
||||
destination.write(child);
|
||||
return renderIterable(destination, child);
|
||||
}
|
||||
destination.write(child);
|
||||
}
|
||||
function renderArray(destination, children) {
|
||||
const flushers = children.map((c) => {
|
||||
return createBufferedRenderer(destination, (bufferDestination) => {
|
||||
return renderChild(bufferDestination, c);
|
||||
});
|
||||
});
|
||||
const iterator = flushers[Symbol.iterator]();
|
||||
const iterate = () => {
|
||||
for (; ; ) {
|
||||
const { value: flusher, done } = iterator.next();
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
const result = flusher.flush();
|
||||
if (isPromise(result)) {
|
||||
return result.then(iterate);
|
||||
}
|
||||
}
|
||||
};
|
||||
return iterate();
|
||||
}
|
||||
function renderIterable(destination, children) {
|
||||
const iterator = children[Symbol.iterator]();
|
||||
const iterate = () => {
|
||||
for (; ; ) {
|
||||
const { value, done } = iterator.next();
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
const result = renderChild(destination, value);
|
||||
if (isPromise(result)) {
|
||||
return result.then(iterate);
|
||||
}
|
||||
}
|
||||
};
|
||||
return iterate();
|
||||
}
|
||||
async function renderAsyncIterable(destination, children) {
|
||||
for await (const value of children) {
|
||||
await renderChild(destination, value);
|
||||
}
|
||||
}
|
||||
export {
|
||||
|
Reference in New Issue
Block a user