Skip to content

Commit 248dc28

Browse files
committed
Merge branch 'main' into deno-jsons-clean
2 parents 4143d09 + fcd9480 commit 248dc28

15 files changed

Lines changed: 181 additions & 144 deletions

File tree

deno.lock

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

docs/latest/examples/client-side-components-and-libraries.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function LeafletProvider(props: { children: ComponentChildren }) {
5353
<p>Leaflet must be loaded on the client. No children will render</p>
5454
);
5555
}
56-
const [value, setValue] = useState<typeof Leaflet | null>(null);
56+
const value = useSignal<typeof Leaflet | null>(null)
5757
return (
5858
<>
5959
{/* Load Leaflet CSS */}
@@ -65,7 +65,7 @@ function LeafletProvider(props: { children: ComponentChildren }) {
6565
/>
6666
{/* Load Leaflet JS */}
6767
<script
68-
onLoad={() => setValue(window.L)}
68+
onLoad={() => value.value = window.L}
6969
src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
7070
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
7171
crossorigin=""
@@ -120,8 +120,9 @@ export default function MapIsland() {
120120
```tsx MapIsland.tsx
121121
import * as Leaflet from "https://esm.sh/v135/@types/leaflet@1.9.4/index.d.ts";
122122
import { IS_BROWSER } from "$fresh/runtime.ts";
123-
import { useContext, useEffect, useState } from "preact/hooks";
123+
import { useContext, useEffect } from "preact/hooks";
124124
import { ComponentChildren, createContext } from "preact";
125+
import { useSignal } from "@preact/signals";
125126

126127
// Create a context to hold Leaflet data/functions
127128
const LeafletContext = createContext<typeof Leaflet | null>(null);
@@ -131,7 +132,7 @@ function LeafletProvider(props: { children: ComponentChildren }) {
131132
if (!IS_BROWSER) {
132133
return <p>Leaflet must be loaded on the client. No children will render</p>;
133134
}
134-
const [value, setValue] = useState<typeof Leaflet | null>(null);
135+
const value = useSignal<typeof Leaflet | null>(null);
135136
return (
136137
<>
137138
{/* Load Leaflet CSS */}
@@ -143,7 +144,7 @@ function LeafletProvider(props: { children: ComponentChildren }) {
143144
/>
144145
{/* Load Leaflet JS */}
145146
<script
146-
onLoad={() => setValue(window.L)}
147+
onLoad={() => value.value = window.L}
147148
src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
148149
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
149150
crossorigin=""

init/src/init_test.ts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,31 @@ Deno.test("init - with vscode", async () => {
121121
});
122122
});
123123

124-
Deno.test("init - fmt, lint, and type check project", async () => {
125-
await withTmpDir(async (dir) => {
126-
const mock = mockUserInput({
127-
[InitStep.ProjectName]: ".",
124+
Deno.test({
125+
name: "init - fmt, lint, and type check project",
126+
// Ignore this test on canary due to different formatting
127+
// behaviours when the formatter changes.
128+
ignore: Deno.version.deno.includes("+"),
129+
fn: async () => {
130+
await withTmpDir(async (dir) => {
131+
const mock = mockUserInput({
132+
[InitStep.ProjectName]: ".",
133+
});
134+
await initProject(dir, [], {}, mock.tty);
135+
await expectProjectFile(dir, "main.ts");
136+
await expectProjectFile(dir, "dev.ts");
137+
138+
await patchProject(dir);
139+
140+
const check = await new Deno.Command(Deno.execPath(), {
141+
args: ["task", "check"],
142+
cwd: dir,
143+
stderr: "inherit",
144+
stdout: "inherit",
145+
}).output();
146+
expect(check.code).toEqual(0);
128147
});
129-
await initProject(dir, [], {}, mock.tty);
130-
await expectProjectFile(dir, "main.ts");
131-
await expectProjectFile(dir, "dev.ts");
132-
133-
await patchProject(dir);
134-
135-
const check = await new Deno.Command(Deno.execPath(), {
136-
args: ["task", "check"],
137-
cwd: dir,
138-
stderr: "inherit",
139-
stdout: "inherit",
140-
}).output();
141-
expect(check.code).toEqual(0);
142-
});
148+
},
143149
});
144150

145151
Deno.test("init with tailwind - fmt, lint, and type check project", async () => {

init/src/mod.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { initProject } from "./init.ts";
33
import { InitError } from "./init.ts";
44

55
const flags = parseArgs(Deno.args, {
6-
boolean: ["force", "tailwind", "twind", "vscode", "docker", "help"],
6+
boolean: ["force", "tailwind", "vscode", "docker", "help"],
77
default: {
88
force: null,
99
tailwind: null,
10-
twind: null,
1110
vscode: null,
1211
docker: null,
1312
},

src/app.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,19 @@ export class App<State> {
295295
}
296296

297297
try {
298+
let result: unknown;
298299
if (handlers.length === 1 && handlers[0].length === 1) {
299-
return handlers[0][0](ctx);
300+
result = await handlers[0][0](ctx);
301+
} else {
302+
result = await runMiddlewares(handlers, ctx);
300303
}
301-
return await runMiddlewares(handlers, ctx);
304+
if (!(result instanceof Response)) {
305+
throw new Error(
306+
`Expected a "Response" instance to be returned, but got: ${result}`,
307+
);
308+
}
309+
310+
return result;
302311
} catch (err) {
303312
if (err instanceof HttpError) {
304313
if (err.status >= 500) {

0 commit comments

Comments
 (0)