[ci] format
This commit is contained in:
parent
3daaf510ea
commit
69c955b2bf
5 changed files with 70 additions and 70 deletions
|
@ -83,9 +83,7 @@ export interface RenderOptions {
|
|||
request: Request;
|
||||
}
|
||||
|
||||
export async function render(
|
||||
opts: RenderOptions
|
||||
): Promise<Response> {
|
||||
export async function render(opts: RenderOptions): Promise<Response> {
|
||||
const {
|
||||
links,
|
||||
styles,
|
||||
|
|
|
@ -632,7 +632,9 @@ export async function renderToIterable(
|
|||
const Component = await componentFactory(result, props, children);
|
||||
|
||||
if (!isAstroComponent(Component)) {
|
||||
console.warn(`Returning a Response is only supported inside of page components. Consider refactoring this logic into something like a function that can be used in the page.`);
|
||||
console.warn(
|
||||
`Returning a Response is only supported inside of page components. Consider refactoring this logic into something like a function that can be used in the page.`
|
||||
);
|
||||
const response: Response = Component;
|
||||
throw response;
|
||||
}
|
||||
|
@ -669,7 +671,7 @@ export async function renderPage(
|
|||
controller.close();
|
||||
}
|
||||
read();
|
||||
}
|
||||
},
|
||||
});
|
||||
let init = result.response;
|
||||
let response = createResponse(stream, init);
|
||||
|
@ -716,7 +718,9 @@ export function maybeRenderHead(result: SSRResult): string | Promise<string> {
|
|||
return renderHead(result);
|
||||
}
|
||||
|
||||
export async function * renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string> {
|
||||
export async function* renderAstroComponent(
|
||||
component: InstanceType<typeof AstroComponent>
|
||||
): AsyncIterable<string> {
|
||||
for await (const value of component) {
|
||||
if (value || value === 0) {
|
||||
for await (const chunk of _render(value)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
const isNodeJS = typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]';
|
||||
const isNodeJS =
|
||||
typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]';
|
||||
|
||||
let StreamingCompatibleResponse: typeof Response | undefined;
|
||||
|
||||
|
@ -56,16 +56,18 @@ function createResponseClass() {
|
|||
}
|
||||
return super.arrayBuffer();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return StreamingCompatibleResponse;
|
||||
}
|
||||
|
||||
type CreateResponseFn = (body?: BodyInit | null, init?: ResponseInit) => Response;
|
||||
|
||||
export const createResponse: CreateResponseFn = isNodeJS ? (body, init) => {
|
||||
export const createResponse: CreateResponseFn = isNodeJS
|
||||
? (body, init) => {
|
||||
if (typeof StreamingCompatibleResponse === 'undefined') {
|
||||
return new (createResponseClass())(body, init);
|
||||
}
|
||||
return new StreamingCompatibleResponse(body, init);
|
||||
} : (body, init) => new Response(body, init);
|
||||
}
|
||||
: (body, init) => new Response(body, init);
|
||||
|
|
|
@ -98,10 +98,7 @@ async function writeWebResponse(res: http.ServerResponse, webResponse: Response)
|
|||
res.end();
|
||||
}
|
||||
|
||||
async function writeSSRResult(
|
||||
webResponse: Response,
|
||||
res: http.ServerResponse
|
||||
) {
|
||||
async function writeSSRResult(webResponse: Response, res: http.ServerResponse) {
|
||||
return writeWebResponse(res, webResponse);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { expect } from 'chai';
|
|||
import testAdapter from './test-adapter.js';
|
||||
import * as cheerio from 'cheerio';
|
||||
|
||||
|
||||
describe('Streaming', () => {
|
||||
if (isWindows) return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue