|
1 | 1 | // TODO make fresh plugin use @deco/deco from JSR. so that we can use the same code for both |
2 | 2 |
|
3 | | -import type { AppManifest, DecoContext, SiteInfo } from "@deco/deco"; |
| 3 | +import type { Plugin } from "$fresh/server.ts"; |
| 4 | +import type { AppManifest, DecoContext, Framework, SiteInfo } from "@deco/deco"; |
4 | 5 | import { Deco, type PageData, type PageParams } from "@deco/deco"; |
5 | 6 | import { framework as htmxFramework } from "@deco/deco/htmx"; |
6 | 7 | import type { ComponentType } from "preact"; |
7 | | -import framework from "./Bindings.tsx"; |
8 | | -import type { Plugin } from "$fresh/server.ts"; |
9 | 8 | import type { Bindings } from "../handler.tsx"; |
| 9 | +import freshFramework from "./Bindings.tsx"; |
10 | 10 | export type { Plugin } from "$fresh/server.ts"; |
11 | 11 |
|
12 | 12 | export interface PluginRoute { |
@@ -51,6 +51,7 @@ export interface InitOptions<TManifest extends AppManifest = AppManifest> { |
51 | 51 | htmx?: boolean; |
52 | 52 | site?: SiteInfo; |
53 | 53 | deco?: Deco<TManifest>; |
| 54 | + ErrorFallback?: Framework["ErrorFallback"]; |
54 | 55 | useServer?: Bindings<TManifest>["useServer"]; |
55 | 56 | middlewares?: PluginMiddleware[]; |
56 | 57 | visibilityOverrides?: DecoContext<TManifest>["visibilityOverrides"]; |
@@ -87,12 +88,17 @@ export default function decoPlugin<TManifest extends AppManifest = AppManifest>( |
87 | 88 | throw new Error(`functions opts are not supported`); |
88 | 89 | } |
89 | 90 |
|
| 91 | + const framework = opt?.htmx ? htmxFramework : freshFramework; |
| 92 | + |
90 | 93 | const decoPromise = opt.deco instanceof Deco ? opt.deco : Deco.init({ |
91 | 94 | manifest: opt.manifest, |
92 | 95 | site: opt?.site?.name, |
93 | 96 | namespace: opt?.site?.namespace, |
94 | 97 | bindings: { |
95 | | - framework: opt?.htmx ? htmxFramework : framework, |
| 98 | + framework: { |
| 99 | + ...framework, |
| 100 | + ErrorFallback: opt.ErrorFallback ?? framework.ErrorFallback, |
| 101 | + }, |
96 | 102 | useServer: opt?.useServer, |
97 | 103 | }, |
98 | 104 | visibilityOverrides: opt.visibilityOverrides, |
|
0 commit comments