fondu 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/client/app.js +21 -1
- package/dist/server/document.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,18 @@ on Cloudflare Workers with D1 and Better Auth.
|
|
|
31
31
|
server and client code, server-side rendering, static pages, MDX pages, internationalization, deploying, and the API.
|
|
32
32
|
Every page is also Markdown for coding agents ([llms.txt](https://fondu.dev/llms.txt)).
|
|
33
33
|
|
|
34
|
+
## For coding agents
|
|
35
|
+
|
|
36
|
+
Fondu's rules for an app (routes, pages, forms, navigation, data, rendering, the server, types) are an agent skill,
|
|
37
|
+
[`skills/fondu/`](https://github.com/fondujs/fondu/tree/main/skills/fondu), kept here with the code it describes. Install it in an app with the
|
|
38
|
+
[`skills`](https://github.com/vercel-labs/skills) CLI:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx skills add fondujs/fondu
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
An app's `AGENTS.md` then says only what is the app's own.
|
|
45
|
+
|
|
34
46
|
## Contributing
|
|
35
47
|
|
|
36
48
|
```
|
package/dist/client/app.js
CHANGED
|
@@ -68,7 +68,27 @@ class Failed extends Component {
|
|
|
68
68
|
render() {
|
|
69
69
|
if (!this.state.failed)
|
|
70
70
|
return this.props.children;
|
|
71
|
-
return ErrorPage
|
|
71
|
+
return ErrorPage
|
|
72
|
+
? createElement(Unfailing, null, createElement(ErrorPage, { status: 500 }))
|
|
73
|
+
: PLAIN;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const PLAIN = 'Something went wrong';
|
|
77
|
+
/**
|
|
78
|
+
* The error page's own boundary: `Failed` renders the error page outside its own reach, so an error page that throws
|
|
79
|
+
* would escape every boundary and React would unmount the app (a blank page). Plain text instead, and the error in
|
|
80
|
+
* the console: the app's author must see it.
|
|
81
|
+
*/
|
|
82
|
+
class Unfailing extends Component {
|
|
83
|
+
state = { failed: false };
|
|
84
|
+
static getDerivedStateFromError() {
|
|
85
|
+
return { failed: true };
|
|
86
|
+
}
|
|
87
|
+
componentDidCatch(error) {
|
|
88
|
+
console.error('[fondu] the error page failed to render:', error);
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
return this.state.failed ? PLAIN : this.props.children;
|
|
72
92
|
}
|
|
73
93
|
}
|
|
74
94
|
/**
|
package/dist/server/document.js
CHANGED
|
@@ -94,6 +94,10 @@ export async function renderDocument(c, page, whole = false) {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
catch (error) {
|
|
97
|
+
// the error page's failure goes to `errorResponse`: plain text with the status (the browser would render the
|
|
98
|
+
// same props and most likely fail again, and a visitor without JavaScript would get nothing)
|
|
99
|
+
if (page.component === '_error')
|
|
100
|
+
throw error;
|
|
97
101
|
// like Laravel: a page that fails to render on the server is still sent, and rendered in the browser
|
|
98
102
|
console.error(`[fondu] server render of "${page.component}" failed, sending it to render in the browser:`, error);
|
|
99
103
|
}
|