[ci] format

This commit is contained in:
matthewp 2023-02-07 15:58:53 +00:00 committed by fredkbot
parent d1f5611feb
commit b5f772ec7b
15 changed files with 56 additions and 44 deletions

View file

@ -170,7 +170,13 @@ async function render({
return createHeadAndContent(
unescapeHTML(styles + links + scripts) as any,
renderTemplate`${renderComponent(createScopedResult(result), 'Content', mod.Content, props, slots)}`
renderTemplate`${renderComponent(
createScopedResult(result),
'Content',
mod.Content,
props,
slots
)}`
);
},
propagation: 'self',

View file

@ -1,10 +1,10 @@
import type { OutputChunk, RenderedChunk } from 'rollup';
import type { PageBuildData, ViteID } from './types';
import { SSRResult } from '../../@types/astro';
import { PageOptions } from '../../vite-plugin-astro/types';
import { prependForwardSlash, removeFileExtension } from '../path.js';
import { viteID } from '../util.js';
import { SSRResult } from '../../@types/astro';
export interface BuildInternals {
/**

View file

@ -1,4 +1,5 @@
import { astroConfigBuildPlugin } from '../../../content/vite-plugin-content-assets.js';
import { astroHeadPropagationBuildPlugin } from '../../../vite-plugin-head-propagation/index.js';
import type { AstroBuildPluginContainer } from '../plugin';
import { pluginAliasResolve } from './plugin-alias-resolve.js';
import { pluginAnalyzer } from './plugin-analyzer.js';
@ -8,7 +9,6 @@ import { pluginInternals } from './plugin-internals.js';
import { pluginPages } from './plugin-pages.js';
import { pluginPrerender } from './plugin-prerender.js';
import { pluginSSR } from './plugin-ssr.js';
import { astroHeadPropagationBuildPlugin } from '../../../vite-plugin-head-propagation/index.js';
export function registerAllPlugins({ internals, options, register }: AstroBuildPluginContainer) {
register(pluginAliasResolve(internals));

View file

@ -9,7 +9,13 @@ import type {
SSRLoadedRenderer,
SSRResult,
} from '../../@types/astro';
import { renderSlot, stringifyChunk, ScopeFlags, createScopedResult, ComponentSlots } from '../../runtime/server/index.js';
import {
ComponentSlots,
createScopedResult,
renderSlot,
ScopeFlags,
stringifyChunk,
} from '../../runtime/server/index.js';
import { renderJSX } from '../../runtime/server/jsx.js';
import { AstroCookies } from '../cookies/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
@ -104,9 +110,7 @@ class Slots {
const expression = getFunctionExpression(component);
if (expression) {
const slot = () => expression(...args);
return await renderSlot(scoped, slot).then((res) =>
res != null ? String(res) : res
);
return await renderSlot(scoped, slot).then((res) => (res != null ? String(res) : res));
}
// JSX
if (typeof component === 'function') {

View file

@ -33,8 +33,8 @@ export {
export type {
AstroComponentFactory,
AstroComponentInstance,
ComponentSlots,
RenderInstruction,
ComponentSlots
} from './render/index.js';
import { markHTMLString } from './escape.js';

View file

@ -3,7 +3,7 @@ import type { HeadAndContent } from './head-and-content';
import type { RenderTemplateResult } from './render-template';
import { HTMLParts } from '../common.js';
import { addScopeFlag, createScopedResult, ScopeFlags } from '../scope.js';
import { createScopedResult, ScopeFlags } from '../scope.js';
import { isHeadAndContent } from './head-and-content.js';
import { renderAstroTemplateResult } from './render-template.js';

View file

@ -1,13 +1,13 @@
import type { SSRResult } from '../../../../@types/astro';
import type { AstroComponentFactory, AstroFactoryReturnValue } from './factory.js';
import type { ComponentSlots } from '../slot.js';
import type { AstroComponentFactory, AstroFactoryReturnValue } from './factory.js';
import { HydrationDirectiveProps } from '../../hydration.js';
import { isPromise } from '../../util.js';
import { renderChild } from '../any.js';
import { createScopedResult, ScopeFlags } from '../scope.js';
import { isAPropagatingComponent } from './factory.js';
import { isHeadAndContent } from './head-and-content.js';
import { createScopedResult, ScopeFlags } from '../scope.js';
type ComponentProps = Record<string | number, any>;

View file

@ -9,8 +9,8 @@ import {
PrescriptType,
} from '../scripts.js';
import { renderAllHeadContent } from './head.js';
import { isSlotString, type SlotString } from './slot.js';
import { ScopeFlags } from './scope.js';
import { isSlotString, type SlotString } from './slot.js';
export const Fragment = Symbol.for('astro:fragment');
export const Renderer = Symbol.for('astro:renderer');
@ -59,7 +59,7 @@ export function stringifyChunk(result: SSRResult, chunk: string | SlotString | R
// JSX with an Astro slot
case ScopeFlags.JSX | ScopeFlags.Slot | ScopeFlags.Astro:
case ScopeFlags.JSX | ScopeFlags.Astro | ScopeFlags.HeadBuffer:
case ScopeFlags.JSX | ScopeFlags.Slot | ScopeFlags.Astro | ScopeFlags.HeadBuffer: {
case ScopeFlags.JSX | ScopeFlags.Slot | ScopeFlags.Astro | ScopeFlags.HeadBuffer: {
return '';
}

View file

@ -2,7 +2,6 @@ import type { SSRResult } from '../../../@types/astro';
import { markHTMLString } from '../escape.js';
import { renderElement } from './util.js';
import { ScopeFlags } from './scope.js';
// Filter out duplicate elements in our set
const uniqueElements = (item: any, index: number, all: any[]) => {

View file

@ -1,7 +1,4 @@
export type {
AstroComponentFactory,
AstroComponentInstance,
} from './astro/index';
export type { AstroComponentFactory, AstroComponentInstance } from './astro/index';
export {
createHeadAndContent,
renderAstroTemplateResult,
@ -13,8 +10,8 @@ export { renderComponent, renderComponentToIterable } from './component.js';
export { renderHTMLElement } from './dom.js';
export { maybeRenderHead, renderHead } from './head.js';
export { renderPage } from './page.js';
export { addScopeFlag, createScopedResult, removeScopeFlag, ScopeFlags } from './scope.js';
export { renderSlot, type ComponentSlots } from './slot.js';
export { createScopedResult, ScopeFlags, addScopeFlag, removeScopeFlag } from './scope.js';
export { renderScriptElement, renderStyleElement, renderUniqueStylesheet } from './tags.js';
export type { RenderInstruction } from './types';
export { addAttribute, defineScriptVars, voidElementNames } from './util.js';

View file

@ -15,7 +15,7 @@ import {
import { chunkToByteArray, encoder, HTMLParts } from './common.js';
import { renderComponent } from './component.js';
import { maybeRenderHead } from './head.js';
import { addScopeFlag, createScopedResult, removeScopeFlag, ScopeFlags } from './scope.js';
import { createScopedResult, ScopeFlags } from './scope.js';
const needsHeadRenderingSymbol = Symbol.for('astro.needsHeadRendering');

View file

@ -19,13 +19,13 @@ export function removeScopeFlag(result: SSRResult, flag: ScopeFlagValues) {
}
export function createScopedResult(result: SSRResult, flag?: ScopeFlagValues): SSRResult {
const scopedResult = Object.create(result, {
const scopedResult = Object.create(result, {
scope: {
writable: true,
value: result.scope
}
value: result.scope,
},
});
if(flag != null) {
if (flag != null) {
addScopeFlag(scopedResult, flag);
}
return scopedResult;

View file

@ -1,10 +1,10 @@
import type { SSRResult } from '../../../@types/astro.js';
import type { RenderInstruction } from './types.js';
import type { renderTemplate } from './astro/render-template.js';
import type { RenderInstruction } from './types.js';
import { HTMLString, markHTMLString } from '../escape.js';
import { renderChild } from './any.js';
import { ScopeFlags, createScopedResult } from './scope.js';
import { createScopedResult, ScopeFlags } from './scope.js';
type RenderTemplateResult = ReturnType<typeof renderTemplate>;
export type ComponentSlots = Record<string, ComponentSlotValue>;
@ -49,7 +49,7 @@ export async function renderSlot(
return markHTMLString(new SlotString(content, instructions));
}
if(fallback) {
if (fallback) {
return renderSlot(result, fallback);
}
return '';
@ -60,7 +60,10 @@ interface RenderSlotsResult {
children: Record<string, string>;
}
export async function renderSlots(result: SSRResult, slots: ComponentSlots = {}): Promise<RenderSlotsResult> {
export async function renderSlots(
result: SSRResult,
slots: ComponentSlots = {}
): Promise<RenderSlotsResult> {
let slotInstructions: RenderSlotsResult['slotInstructions'] = null;
let children: RenderSlotsResult['children'] = {};
if (slots) {

View file

@ -16,6 +16,9 @@ export type MaybeRenderHeadInstruction = {
type: 'maybe-head';
result: SSRResult;
scope: number;
}
};
export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction | MaybeRenderHeadInstruction;
export type RenderInstruction =
| RenderDirectiveInstruction
| RenderHeadInstruction
| MaybeRenderHeadInstruction;

View file

@ -5,8 +5,8 @@ import type { AstroBuildPlugin } from '../core/build/plugin.js';
import type { StaticBuildOptions } from '../core/build/types';
import * as vite from 'vite';
import { getAstroMetadata } from '../vite-plugin-astro/index.js';
import { walkParentInfos } from '../core/build/graph.js';
import { getAstroMetadata } from '../vite-plugin-astro/index.js';
const injectExp = /^\/\/\s*astro-head-inject/;
/**
@ -79,23 +79,23 @@ export function astroHeadPropagationBuildPlugin(
generateBundle(_opts, bundle) {
const appendPropagation = (info: ModuleInfo) => {
const astroMetadata = getAstroMetadata(info);
if(astroMetadata) {
if (astroMetadata) {
astroMetadata.propagation = 'in-tree';
map.set(info.id, 'in-tree');
}
};
for(const [bundleId, output] of Object.entries(bundle)) {
if(output.type !== 'chunk') continue;
for(const [id, mod] of Object.entries(output.modules)) {
if (mod.code && injectExp.test(mod.code)) {
for(const [info] of walkParentInfos(id, this)) {
for (const [bundleId, output] of Object.entries(bundle)) {
if (output.type !== 'chunk') continue;
for (const [id, mod] of Object.entries(output.modules)) {
if (mod.code && injectExp.test(mod.code)) {
for (const [info] of walkParentInfos(id, this)) {
appendPropagation(info);
}
}
const info = this.getModuleInfo(id);
if(info) {
if (info) {
appendPropagation(info);
}
}
@ -103,10 +103,10 @@ export function astroHeadPropagationBuildPlugin(
// Save the map to internals so it can be passed into SSR and generation
internals.propagation = map;
}
}
}
}
}
}
},
},
};
},
},
};
}