[ci] format
This commit is contained in:
parent
09c1e586ee
commit
45bec97d28
4 changed files with 20 additions and 16 deletions
|
@ -15,7 +15,7 @@ export interface HydrationMetadata {
|
||||||
value: string;
|
value: string;
|
||||||
componentUrl: string;
|
componentUrl: string;
|
||||||
componentExport: { value: string };
|
componentExport: { value: string };
|
||||||
};
|
}
|
||||||
|
|
||||||
interface ExtractedProps {
|
interface ExtractedProps {
|
||||||
isPage: boolean;
|
isPage: boolean;
|
||||||
|
|
|
@ -135,7 +135,7 @@ export async function renderSlot(result: any, slotted: string, fallback?: any):
|
||||||
let iterator = _render(slotted);
|
let iterator = _render(slotted);
|
||||||
let content = '';
|
let content = '';
|
||||||
for await (const chunk of iterator) {
|
for await (const chunk of iterator) {
|
||||||
if((chunk as any).type === 'directive') {
|
if ((chunk as any).type === 'directive') {
|
||||||
content += stringifyChunk(result, chunk);
|
content += stringifyChunk(result, chunk);
|
||||||
} else {
|
} else {
|
||||||
content += chunk;
|
content += chunk;
|
||||||
|
@ -230,7 +230,11 @@ export async function renderComponent(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Component && (Component as any).isAstroComponentFactory) {
|
if (Component && (Component as any).isAstroComponentFactory) {
|
||||||
async function* renderAstroComponentInline(): AsyncGenerator<string | RenderInstruction, void, undefined> {
|
async function* renderAstroComponentInline(): AsyncGenerator<
|
||||||
|
string | RenderInstruction,
|
||||||
|
void,
|
||||||
|
undefined
|
||||||
|
> {
|
||||||
let iterable = await renderToIterable(result, Component as any, _props, slots);
|
let iterable = await renderToIterable(result, Component as any, _props, slots);
|
||||||
yield* iterable;
|
yield* iterable;
|
||||||
}
|
}
|
||||||
|
@ -482,7 +486,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
||||||
island.props['await-children'] = '';
|
island.props['await-children'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
async function * renderAll() {
|
async function* renderAll() {
|
||||||
yield { type: 'directive', hydration, result };
|
yield { type: 'directive', hydration, result };
|
||||||
yield markHTMLString(renderElement('astro-island', island, false));
|
yield markHTMLString(renderElement('astro-island', island, false));
|
||||||
}
|
}
|
||||||
|
@ -777,7 +781,7 @@ const encoder = new TextEncoder();
|
||||||
// These directive instructions bubble all the way up to renderPage so that we
|
// These directive instructions bubble all the way up to renderPage so that we
|
||||||
// can ensure they are added only once, and as soon as possible.
|
// can ensure they are added only once, and as soon as possible.
|
||||||
export function stringifyChunk(result: SSRResult, chunk: string | RenderInstruction) {
|
export function stringifyChunk(result: SSRResult, chunk: string | RenderInstruction) {
|
||||||
switch((chunk as any).type) {
|
switch ((chunk as any).type) {
|
||||||
case 'directive': {
|
case 'directive': {
|
||||||
const { hydration } = chunk as RenderInstruction;
|
const { hydration } = chunk as RenderInstruction;
|
||||||
let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
|
let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
|
||||||
|
@ -785,11 +789,11 @@ export function stringifyChunk(result: SSRResult, chunk: string | RenderInstruct
|
||||||
hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
|
hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
|
||||||
|
|
||||||
let prescriptType: PrescriptType = needsHydrationScript
|
let prescriptType: PrescriptType = needsHydrationScript
|
||||||
? 'both'
|
? 'both'
|
||||||
: needsDirectiveScript
|
: needsDirectiveScript
|
||||||
? 'directive'
|
? 'directive'
|
||||||
: null;
|
: null;
|
||||||
if(prescriptType) {
|
if (prescriptType) {
|
||||||
let prescripts = getPrescripts(prescriptType, hydration.directive);
|
let prescripts = getPrescripts(prescriptType, hydration.directive);
|
||||||
return markHTMLString(prescripts);
|
return markHTMLString(prescripts);
|
||||||
} else {
|
} else {
|
||||||
|
@ -942,7 +946,7 @@ export async function* renderAstroComponent(
|
||||||
for await (const value of component) {
|
for await (const value of component) {
|
||||||
if (value || value === 0) {
|
if (value || value === 0) {
|
||||||
for await (const chunk of _render(value)) {
|
for await (const chunk of _render(value)) {
|
||||||
switch(chunk.type) {
|
switch (chunk.type) {
|
||||||
case 'directive': {
|
case 'directive': {
|
||||||
yield chunk;
|
yield chunk;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -6,8 +6,8 @@ import {
|
||||||
escapeHTML,
|
escapeHTML,
|
||||||
HTMLString,
|
HTMLString,
|
||||||
markHTMLString,
|
markHTMLString,
|
||||||
RenderInstruction,
|
|
||||||
renderComponent,
|
renderComponent,
|
||||||
|
RenderInstruction,
|
||||||
renderToString,
|
renderToString,
|
||||||
spreadAttributes,
|
spreadAttributes,
|
||||||
stringifyChunk,
|
stringifyChunk,
|
||||||
|
@ -139,7 +139,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {
|
||||||
slots
|
slots
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(typeof output !== 'string' && Symbol.asyncIterator in output) {
|
if (typeof output !== 'string' && Symbol.asyncIterator in output) {
|
||||||
let body = '';
|
let body = '';
|
||||||
for await (const chunk of output) {
|
for await (const chunk of output) {
|
||||||
let html = stringifyChunk(result, chunk);
|
let html = stringifyChunk(result, chunk);
|
||||||
|
|
|
@ -8,10 +8,10 @@ import visiblePrebuilt from '../client/visible.prebuilt.js';
|
||||||
import islandScript from './astro-island.prebuilt.js';
|
import islandScript from './astro-island.prebuilt.js';
|
||||||
|
|
||||||
export function determineIfNeedsHydrationScript(result: SSRResult): boolean {
|
export function determineIfNeedsHydrationScript(result: SSRResult): boolean {
|
||||||
if(result._metadata.hasHydrationScript) {
|
if (result._metadata.hasHydrationScript) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return result._metadata.hasHydrationScript = true;
|
return (result._metadata.hasHydrationScript = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const hydrationScripts: Record<string, string> = {
|
export const hydrationScripts: Record<string, string> = {
|
||||||
|
@ -23,7 +23,7 @@ export const hydrationScripts: Record<string, string> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function determinesIfNeedsDirectiveScript(result: SSRResult, directive: string): boolean {
|
export function determinesIfNeedsDirectiveScript(result: SSRResult, directive: string): boolean {
|
||||||
if(result._metadata.hasDirectives.has(directive)) {
|
if (result._metadata.hasDirectives.has(directive)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
result._metadata.hasDirectives.add(directive);
|
result._metadata.hasDirectives.add(directive);
|
||||||
|
|
Loading…
Reference in a new issue