0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] format

This commit is contained in:
matthewp 2022-07-29 14:48:08 +00:00 committed by fredkbot
parent 09c1e586ee
commit 45bec97d28
4 changed files with 20 additions and 16 deletions

View file

@ -15,7 +15,7 @@ export interface HydrationMetadata {
value: string;
componentUrl: string;
componentExport: { value: string };
};
}
interface ExtractedProps {
isPage: boolean;

View file

@ -135,7 +135,7 @@ export async function renderSlot(result: any, slotted: string, fallback?: any):
let iterator = _render(slotted);
let content = '';
for await (const chunk of iterator) {
if((chunk as any).type === 'directive') {
if ((chunk as any).type === 'directive') {
content += stringifyChunk(result, chunk);
} else {
content += chunk;
@ -230,7 +230,11 @@ export async function renderComponent(
}
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);
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'] = '';
}
async function * renderAll() {
async function* renderAll() {
yield { type: 'directive', hydration, result };
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
// can ensure they are added only once, and as soon as possible.
export function stringifyChunk(result: SSRResult, chunk: string | RenderInstruction) {
switch((chunk as any).type) {
switch ((chunk as any).type) {
case 'directive': {
const { hydration } = chunk as RenderInstruction;
let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
@ -785,11 +789,11 @@ export function stringifyChunk(result: SSRResult, chunk: string | RenderInstruct
hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
let prescriptType: PrescriptType = needsHydrationScript
? 'both'
: needsDirectiveScript
? 'directive'
: null;
if(prescriptType) {
? 'both'
: needsDirectiveScript
? 'directive'
: null;
if (prescriptType) {
let prescripts = getPrescripts(prescriptType, hydration.directive);
return markHTMLString(prescripts);
} else {
@ -942,7 +946,7 @@ export async function* renderAstroComponent(
for await (const value of component) {
if (value || value === 0) {
for await (const chunk of _render(value)) {
switch(chunk.type) {
switch (chunk.type) {
case 'directive': {
yield chunk;
break;

View file

@ -6,8 +6,8 @@ import {
escapeHTML,
HTMLString,
markHTMLString,
RenderInstruction,
renderComponent,
RenderInstruction,
renderToString,
spreadAttributes,
stringifyChunk,
@ -139,7 +139,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {
slots
);
}
if(typeof output !== 'string' && Symbol.asyncIterator in output) {
if (typeof output !== 'string' && Symbol.asyncIterator in output) {
let body = '';
for await (const chunk of output) {
let html = stringifyChunk(result, chunk);

View file

@ -8,10 +8,10 @@ import visiblePrebuilt from '../client/visible.prebuilt.js';
import islandScript from './astro-island.prebuilt.js';
export function determineIfNeedsHydrationScript(result: SSRResult): boolean {
if(result._metadata.hasHydrationScript) {
if (result._metadata.hasHydrationScript) {
return false;
}
return result._metadata.hasHydrationScript = true;
return (result._metadata.hasHydrationScript = true);
}
export const hydrationScripts: Record<string, string> = {
@ -23,7 +23,7 @@ export const hydrationScripts: Record<string, string> = {
};
export function determinesIfNeedsDirectiveScript(result: SSRResult, directive: string): boolean {
if(result._metadata.hasDirectives.has(directive)) {
if (result._metadata.hasDirectives.has(directive)) {
return false;
}
result._metadata.hasDirectives.add(directive);