feat: update for Deno 2 (#2655)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Marvin Hagemeister
2024-09-30 18:30:30 +02:00
committed by GitHub
co-authored by Luca Casonato
parent b5389f69a3
commit de8f1b0c59
32 changed files with 3836 additions and 3194 deletions
+6 -4
View File
@@ -15,6 +15,11 @@ export type AsyncAnyComponent<P> = {
defaultProps?: Partial<P> | undefined;
};
// deno-lint-ignore no-explicit-any
export function isAsyncAnyComponent(fn: any): fn is AsyncAnyComponent<any> {
return typeof fn === "function" && fn.constructor.name === "AsyncFunction";
}
export function renderMiddleware<State>(
components: Array<
| AnyComponent<PageProps<unknown, State>>
@@ -50,10 +55,7 @@ export function renderMiddleware<State>(
const fn = components[i];
if (
typeof fn === "function" &&
fn.constructor.name === "AsyncFunction"
) {
if (isAsyncAnyComponent(fn)) {
const result = (await fn(props)) as VNode | Response;
if (result instanceof Response) {
return result;