Skip to content

Commit 6183fd9

Browse files
authored
Allow passing ErrorFallback for frameworks (#930)
Signed-off-by: Marcos Candeia <marrcooos@gmail.com>
1 parent a0fc966 commit 6183fd9

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

.github/workflows/releaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,4 @@ jobs:
179179
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
180180
-H "Accept: application/vnd.github.everest-preview+json" \
181181
https://api.github.com/repos/${{ github.repository }}/actions/workflows/publish.yaml/dispatches \
182-
-d '{"ref":"main", "inputs":{"tag_name":"${{ steps.determine_version.outputs.new_version }}"}}'
182+
-d '{"ref":"main", "inputs":{"tag_name":"${{ steps.determine_version.outputs.new_version }}"}}'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<img src="https://github.com/deco-cx/deco/assets/1633518/ba714da8-514e-4b48-bbec-b7d86377b273" alt="deco" width="210px"/>
3-
</p>
3+
</p>
44
<p align="center">
55
<strong>Git-based Visual CMS for Deno, &lt;/>htmx and Tailwind Apps.</strong>
66
</p>

blocks/loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
OTEL_ENABLE_EXTRA_METRICS,
1616
} from "../observability/otel/metrics.ts";
1717
import { caches, ENABLE_LOADER_CACHE } from "../runtime/caches/mod.ts";
18-
import { DebugProperties } from "../utils/vary.ts";
18+
import type { DebugProperties } from "../utils/vary.ts";
1919
import type { HttpContext } from "./handler.ts";
2020
import {
2121
applyProps,

runtime/fresh/plugin.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// TODO make fresh plugin use @deco/deco from JSR. so that we can use the same code for both
22

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";
45
import { Deco, type PageData, type PageParams } from "@deco/deco";
56
import { framework as htmxFramework } from "@deco/deco/htmx";
67
import type { ComponentType } from "preact";
7-
import framework from "./Bindings.tsx";
8-
import type { Plugin } from "$fresh/server.ts";
98
import type { Bindings } from "../handler.tsx";
9+
import freshFramework from "./Bindings.tsx";
1010
export type { Plugin } from "$fresh/server.ts";
1111

1212
export interface PluginRoute {
@@ -51,6 +51,7 @@ export interface InitOptions<TManifest extends AppManifest = AppManifest> {
5151
htmx?: boolean;
5252
site?: SiteInfo;
5353
deco?: Deco<TManifest>;
54+
ErrorFallback?: Framework["ErrorFallback"];
5455
useServer?: Bindings<TManifest>["useServer"];
5556
middlewares?: PluginMiddleware[];
5657
visibilityOverrides?: DecoContext<TManifest>["visibilityOverrides"];
@@ -87,12 +88,17 @@ export default function decoPlugin<TManifest extends AppManifest = AppManifest>(
8788
throw new Error(`functions opts are not supported`);
8889
}
8990

91+
const framework = opt?.htmx ? htmxFramework : freshFramework;
92+
9093
const decoPromise = opt.deco instanceof Deco ? opt.deco : Deco.init({
9194
manifest: opt.manifest,
9295
site: opt?.site?.name,
9396
namespace: opt?.site?.namespace,
9497
bindings: {
95-
framework: opt?.htmx ? htmxFramework : framework,
98+
framework: {
99+
...framework,
100+
ErrorFallback: opt.ErrorFallback ?? framework.ErrorFallback,
101+
},
96102
useServer: opt?.useServer,
97103
},
98104
visibilityOverrides: opt.visibilityOverrides,

0 commit comments

Comments
 (0)