Skip to content

Commit b26ba88

Browse files
authored
Merge branch 'main' into remove-compat
2 parents ec88050 + 45ce7e3 commit b26ba88

7 files changed

Lines changed: 157 additions & 82 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ jobs:
5050

5151
- name: Run tests
5252
run: deno task test
53+
54+
- name: Check docs
55+
run: deno task check:docs

deno.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"build-www": "deno task --cwd=www build",
2323
"screenshot": "deno run -A www/utils/screenshot.ts",
2424
"check:types": "deno check src/**/*.ts src/**/*.tsx tests/**/*.ts tests/**/*.tsx update/**/*.ts plugin-tailwindcss/**/*.ts init/**/*.ts",
25+
"check:docs": "deno run -A tools/check_docs.ts",
2526
"ok": "deno fmt --check && deno lint && deno task check:types && deno task test",
2627
"test:www": "deno test -A www/main_test.*",
2728
"release": "deno run -A tools/release.ts"
@@ -40,6 +41,8 @@
4041
"exclude": ["**/*_test.*", "src/__OLD/**", "*.todo"]
4142
},
4243
"imports": {
44+
"@deno/doc": "jsr:@deno/doc@^0.172.0",
45+
"@std/collections": "jsr:@std/collections@^1.0.11",
4346
"@std/http": "jsr:@std/http@^1.0.15",
4447
"fresh": "jsr:@fresh/core@^2.0.0-alpha.26",
4548
"preact": "npm:preact@^10.25.1",

deno.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

init/src/init.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export default {
215215
await writeFile("tailwind.config.ts", TAILWIND_CONFIG_TS);
216216
}
217217

218+
// deno-fmt-ignore
218219
const GRADIENT_CSS = css`.fresh-gradient {
219220
background-color: rgb(134, 239, 172);
220221
background-image: linear-gradient(

src/dev/middlewares/error_overlay/overlay.tsx

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,88 @@ const css = (arr: TemplateStringsArray, ...exts: never[]) => {
88

99
export const errorCss = css`
1010
:root {
11-
--bg: #fff;
12-
--bg-code-frame: rgb(255, 0, 32, 0.1);
13-
--bg-active-line: #fbcecc;
14-
--text: #222;
15-
--text2: #444;
16-
--title: #e84644;
17-
--code: #333;
18-
font-family: sans-serif;
19-
line-height: 1.4;
20-
color: var(--text);
21-
background: var(--bg);
22-
}
23-
24-
* {
25-
box-sizing: border-box;
26-
padding: 0;
27-
margin: 0;
28-
}
29-
30-
@media (prefers-color-scheme: dark) {
31-
:root {
32-
--bg-code-frame: rgba(251, 93, 113, 0.2);
33-
--bg-active-line: #4f1919;
34-
--bg: #353535;
35-
--text: #f7f7f7;
36-
--text2: #ddd;
37-
--code: #fdd1d1;
38-
}
39-
}
40-
41-
.inner {
42-
max-width: 48rem;
43-
padding: 4rem 1rem;
44-
margin: 0 auto;
45-
}
46-
47-
.title {
48-
color: var(--title);
49-
font-weight: normal;
50-
font-size: 1.5rem;
51-
margin-bottom: 1rem;
52-
}
53-
54-
.code-frame {
55-
overflow: auto;
56-
padding: 0.5rem;
57-
margin-bottom: 0.5rem;
58-
background: var(--bg-code-frame);
59-
color: var(--code);
60-
}
61-
.line {
62-
padding: 0.25rem 0.5rem;
63-
}
64-
.active-line {
65-
display: inline-block;
66-
width: 100%;
67-
background: var(--bg-active-line);
68-
}
69-
70-
.stack {
71-
overflow-x: auto;
72-
}
73-
74-
.close-btn {
75-
position: absolute;
76-
top: 1rem;
77-
right: 1rem;
78-
color: var(--title);
79-
display: block;
80-
width: 3rem;
81-
height: 3rem;
82-
background: none;
83-
border: none;
84-
transform: translate3d(0, 0, 0);
85-
}
86-
.close-btn:active {
87-
transform: translate3d(0, 2px, 0);
88-
}
89-
.close-btn:hover {
90-
cursor: pointer;
91-
filter: drop-shadow(0 0 0.75rem crimson);
92-
}
11+
--bg: #fff;
12+
--bg-code-frame: rgb(255, 0, 32, 0.1);
13+
--bg-active-line: #fbcecc;
14+
--text: #222;
15+
--text2: #444;
16+
--title: #e84644;
17+
--code: #333;
18+
font-family: sans-serif;
19+
line-height: 1.4;
20+
color: var(--text);
21+
background: var(--bg);
22+
}
23+
24+
* {
25+
box-sizing: border-box;
26+
padding: 0;
27+
margin: 0;
28+
}
29+
30+
@media (prefers-color-scheme: dark) {
31+
:root {
32+
--bg-code-frame: rgba(251, 93, 113, 0.2);
33+
--bg-active-line: #4f1919;
34+
--bg: #353535;
35+
--text: #f7f7f7;
36+
--text2: #ddd;
37+
--code: #fdd1d1;
38+
}
39+
}
40+
41+
.inner {
42+
max-width: 48rem;
43+
padding: 4rem 1rem;
44+
margin: 0 auto;
45+
}
46+
47+
.title {
48+
color: var(--title);
49+
font-weight: normal;
50+
font-size: 1.5rem;
51+
margin-bottom: 1rem;
52+
}
53+
54+
.code-frame {
55+
overflow: auto;
56+
padding: 0.5rem;
57+
margin-bottom: 0.5rem;
58+
background: var(--bg-code-frame);
59+
color: var(--code);
60+
}
61+
.line {
62+
padding: 0.25rem 0.5rem;
63+
}
64+
.active-line {
65+
display: inline-block;
66+
width: 100%;
67+
background: var(--bg-active-line);
68+
}
69+
70+
.stack {
71+
overflow-x: auto;
72+
}
73+
74+
.close-btn {
75+
position: absolute;
76+
top: 1rem;
77+
right: 1rem;
78+
color: var(--title);
79+
display: block;
80+
width: 3rem;
81+
height: 3rem;
82+
background: none;
83+
border: none;
84+
transform: translate3d(0, 0, 0);
85+
}
86+
.close-btn:active {
87+
transform: translate3d(0, 2px, 0);
88+
}
89+
.close-btn:hover {
90+
cursor: pointer;
91+
filter: drop-shadow(0 0 0.75rem crimson);
92+
}
9393
`;
9494

9595
function CodeFrame(props: { codeFrame: string }) {

src/error.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,69 @@
11
import { STATUS_TEXT } from "@std/http/status";
22

3+
/**
4+
* Error that's thrown when a request fails. Correlates to a
5+
* {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status | HTTP status}.
6+
*
7+
* @property status The HTTP status code.
8+
*
9+
* @example Basic usage
10+
* ```ts
11+
* import { App, HttpError } from "fresh";
12+
* import { expect } from "@std/expect";
13+
*
14+
* const app = new App()
15+
* .get("/", () => new Response("ok"))
16+
* .get("/not-found", () => {
17+
* throw new HttpError(404, "Nothing here");
18+
* });
19+
*
20+
* const handler = await app.handler();
21+
*
22+
* try {
23+
* await handler(new Request("http://localhost/not-found"))
24+
* } catch (error) {
25+
* expect(error).toBeInstanceOf(HttpError);
26+
* expect(error.status).toBe(404);
27+
* expect(error.message).toBe("Nothing here");
28+
* }
29+
* ```
30+
*/
331
export class HttpError extends Error {
32+
/**
33+
* The HTTP status code.
34+
*
35+
* @example Basic usage
36+
* ```ts
37+
* import { App, HttpError } from "fresh";
38+
* import { expect } from "@std/expect";
39+
*
40+
* const app = new App()
41+
* .get("/", () => new Response("ok"))
42+
* .get("/not-found", () => {
43+
* throw new HttpError(404, "Nothing here");
44+
* });
45+
*
46+
* const handler = await app.handler();
47+
*
48+
* try {
49+
* await handler(new Request("http://localhost/not-found"))
50+
* } catch (error) {
51+
* expect(error).toBeInstanceOf(HttpError);
52+
* expect(error.status).toBe(404);
53+
* expect(error.message).toBe("Nothing here");
54+
* }
55+
* ```
56+
*/
457
status: number;
558

59+
/**
60+
* Constructs a new instance.
61+
*
62+
* @param status The HTTP status code.
63+
* @param message The error message. Defaults to the status text of the given
64+
* status code.
65+
* @param options Optional error options.
66+
*/
667
constructor(
768
status: keyof typeof STATUS_TEXT,
869
message: string = STATUS_TEXT[status],

tools/check_docs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { checkDocs } from "https://github.com/denoland/std/raw/refs/heads/main/_tools/check_docs.ts";
2+
3+
await checkDocs([
4+
import.meta.resolve("../src/error.ts"),
5+
]);

0 commit comments

Comments
 (0)