Skip to content

Commit bbd52c8

Browse files
authored
Update fresh version to 1.0.0 (#9)
1 parent 56f3238 commit bbd52c8

27 files changed

+144
-105
lines changed

client_deps.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

components/Button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsx h */
22

3-
import { h, tw } from "../client_deps.ts";
3+
import { h } from "preact";
4+
import { tw } from "@twind";
45

56
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
67
return (

components/DocsSidebar.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsx h */
22

3-
import { apply, h, tw } from "../client_deps.ts";
3+
import { h } from "preact";
4+
import { apply, tw } from "@twind";
45
import {
56
CATEGORIES,
67
TableOfContentsCategory,
@@ -32,7 +33,9 @@ export function SidebarCategory(props: {
3233

3334
return (
3435
<li class={outerItem}>
35-
<a href={href} class={outerLink}>{title}</a>
36+
<a href={href} class={outerLink}>
37+
{title}
38+
</a>
3639
{entries.length > 0 && (
3740
<ol class={innerList}>
3841
{entries.map((entry) => (
@@ -54,7 +57,9 @@ export function SidebarEntry(props: {
5457
const innerLink = tw`${href == props.path ? linkActive : link} font-normal`;
5558
return (
5659
<li class={innerItem}>
57-
<a href={href} class={innerLink}>{title}</a>
60+
<a href={href} class={innerLink}>
61+
{title}
62+
</a>
5863
</li>
5964
);
6065
}

components/Footer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsx h */
22

3-
import { h, tw } from "../client_deps.ts";
3+
import { h } from "preact";
4+
import { tw } from "@twind";
45

56
const LINKS = [
67
{

components/Icons.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsx h */
22

3-
import { h, tw } from "../client_deps.ts";
3+
import { h } from "preact";
4+
import { tw } from "@twind";
45

56
export function IconMinus() {
67
return (

components/Navbar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsx h */
22

3-
import { h, tw } from "../client_deps.ts";
3+
import { h } from "preact";
4+
import { tw } from "@twind";
45

56
interface NavbarProps {
67
active: string;

deno.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"tasks": {
3-
"dev": "deno run --watch --no-check -A main.ts",
4-
"manifest": "fresh manifest"
3+
"start": "deno run -A --watch=static/,routes/ dev.ts"
54
},
65
"importMap": "import_map.json"
76
}

dev.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env -S deno run -A --watch=static/,routes/
2+
3+
import dev from "$fresh/dev.ts";
4+
5+
await dev(import.meta.url, "./main.ts");

fresh.gen.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
// DO NOT EDIT. This file is generated by `fresh`.
1+
// DO NOT EDIT. This file is generated by fresh.
22
// This file SHOULD be checked into source version control.
3-
// To update this file, run `fresh manifest`.
3+
// This file is automatically updated during development when running `dev.ts`.
44

5-
import * as $0 from "./routes/_render.ts";
6-
import * as $1 from "./routes/docs/[...slug].tsx";
7-
import * as $2 from "./routes/gfm.css.ts";
8-
import * as $3 from "./routes/index.tsx";
9-
import * as $4 from "./routes/wrp-example-guest.tsx";
10-
import * as $5 from "./routes/wrp-example-host.tsx";
11-
import * as $6 from "./routes/wrp-example.tsx";
12-
import * as $7 from "./routes/wrp-iframe-host.tsx";
5+
import * as $0 from "./routes/docs/[...slug].tsx";
6+
import * as $1 from "./routes/gfm.css.ts";
7+
import * as $2 from "./routes/index.tsx";
8+
import * as $3 from "./routes/wrp-example-guest.tsx";
9+
import * as $4 from "./routes/wrp-example-host.tsx";
10+
import * as $5 from "./routes/wrp-example.tsx";
11+
import * as $6 from "./routes/wrp-iframe-host.tsx";
1312
import * as $$0 from "./islands/Counter.tsx";
1413
import * as $$1 from "./islands/WrpExample.tsx";
1514
import * as $$2 from "./islands/WrpExampleGuest.tsx";
@@ -18,14 +17,13 @@ import * as $$4 from "./islands/WrpIframeHost.tsx";
1817

1918
const manifest = {
2019
routes: {
21-
"./routes/_render.ts": $0,
22-
"./routes/docs/[...slug].tsx": $1,
23-
"./routes/gfm.css.ts": $2,
24-
"./routes/index.tsx": $3,
25-
"./routes/wrp-example-guest.tsx": $4,
26-
"./routes/wrp-example-host.tsx": $5,
27-
"./routes/wrp-example.tsx": $6,
28-
"./routes/wrp-iframe-host.tsx": $7,
20+
"./routes/docs/[...slug].tsx": $0,
21+
"./routes/gfm.css.ts": $1,
22+
"./routes/index.tsx": $2,
23+
"./routes/wrp-example-guest.tsx": $3,
24+
"./routes/wrp-example-host.tsx": $4,
25+
"./routes/wrp-example.tsx": $5,
26+
"./routes/wrp-iframe-host.tsx": $6,
2927
},
3028
islands: {
3129
"./islands/Counter.tsx": $$0,

import_map.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
{
22
"imports": {
3-
"react": "https://raw.githubusercontent.com/lucacasonato/fresh/80598d07fd4eed735ea7ee3eb9728d7f5c9b3aa4/runtime.ts"
4-
},
5-
"scopes": {
6-
"https://deno.land/x/wrp": {
7-
"react": "https://raw.githubusercontent.com/lucacasonato/fresh/80598d07fd4eed735ea7ee3eb9728d7f5c9b3aa4/runtime.ts"
8-
}
3+
"$fresh/": "https://fresh.deno.dev/@1.0.0/",
4+
"react": "./utils/preact-deps.ts",
5+
"preact": "./utils/preact-deps.ts",
6+
"preact/hooks": "./utils/preact-deps.ts",
7+
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?deps=preact@10.8.1",
8+
9+
"@twind": "./utils/twind.ts",
10+
"twind": "https://esm.sh/twind@0.16.16",
11+
"twind/": "https://esm.sh/twind@0.16.16/",
12+
13+
"@markdown": "./utils/markdown.ts"
914
}
1015
}

islands/Counter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @jsx h */
2-
import { h, IS_BROWSER, useState } from "../client_deps.ts";
2+
import { h, useState } from "preact";
3+
import { IS_BROWSER } from "$fresh/runtime.ts";
34

45
interface CounterProps {
56
start: number;

islands/WrpExample.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
/** @jsx h */
22
/** @jsxFrag Fragment */
3+
import { Fragment, h, useEffect, useMemo, useState } from "preact";
4+
import { tw } from "@twind";
35
import {
46
createEventBuffer,
57
EventBuffer,
68
} from "https://deno.land/x/pbkit@v0.0.45/core/runtime/async/event-buffer.ts";
7-
import {
8-
Fragment,
9-
h,
10-
tw,
11-
useEffect,
12-
useMemo,
13-
useState,
14-
} from "../client_deps.ts";
159
import {
1610
createWrpChannel,
1711
WrpChannel,

islands/WrpExampleGuest.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
/** @jsx h */
22
/** @jsxFrag Fragment */
3-
import {
4-
Fragment,
5-
h,
6-
tw,
7-
useEffect,
8-
useMemo,
9-
useState,
10-
} from "../client_deps.ts";
3+
import { Fragment, h, useEffect, useMemo, useState } from "preact";
4+
import { tw } from "@twind";
115
import { createWrpChannel } from "https://deno.land/x/wrp@v0.0.5/channel.ts";
126
import useWrpParentSocket from "https://deno.land/x/wrp@v0.0.5/react/useWrpParentSocket.ts";
137
import useWrpClientImpl from "https://deno.land/x/wrp@v0.0.5/react/useWrpClientImpl.ts";
@@ -78,12 +72,12 @@ function useWrpExampleServiceClient() {
7872
const channel = useMemo(() => socket && createWrpChannel(socket), [socket]);
7973
const wrpClientImpl = useWrpClientImpl(channel);
8074
const [serviceClient, setServiceClient] = useState<Service | undefined>(
81-
undefined
75+
undefined,
8276
);
8377
useEffect(() => {
8478
if (!wrpClientImpl) return;
8579
setServiceClient(
86-
createServiceClient(wrpClientImpl, { devtools: { tags: ["WrpClient"] } })
80+
createServiceClient(wrpClientImpl, { devtools: { tags: ["WrpClient"] } }),
8781
);
8882
}, [wrpClientImpl]);
8983
return serviceClient;

islands/WrpExampleHost.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @jsx h */
22
/** @jsxFrag Fragment */
3-
import { Fragment, h, tw, useMemo, useState } from "../client_deps.ts";
3+
import { Fragment, h, useMemo, useState } from "preact";
4+
import { tw } from "@twind";
45
import { createWrpChannel } from "https://deno.land/x/wrp@v0.0.5/channel.ts";
56
import useWrpParentSocket from "https://deno.land/x/wrp@v0.0.5/react/useWrpParentSocket.ts";
67
import useWrpServer from "https://deno.land/x/wrp@v0.0.5/react/useWrpServer.ts";

islands/WrpIframeHost.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
/** @jsx h */
22
/** @jsxFrag Fragment */
3-
import {
4-
Fragment,
5-
h,
6-
tw,
7-
useEffect,
8-
useMemo,
9-
useState,
10-
} from "../client_deps.ts";
3+
import { Fragment, h, useEffect, useMemo, useState } from "preact";
4+
import { tw } from "@twind";
115
import { createWrpChannel } from "https://deno.land/x/wrp@v0.0.5/channel.ts";
126
import useWrpIframeSocket from "https://deno.land/x/wrp@v0.0.5/react/useWrpIframeSocket.ts";
137
import useWrpServer from "https://deno.land/x/wrp@v0.0.5/react/useWrpServer.ts";
@@ -26,8 +20,9 @@ export default function WrpIframeHost() {
2620
res.header({});
2721
const value = getState().sliderValue;
2822
res.send({ value });
29-
const off = stateChanges.on("sliderValue", (value) =>
30-
res.send({ value })
23+
const off = stateChanges.on(
24+
"sliderValue",
25+
(value) => res.send({ value }),
3126
);
3227
req.metadata?.on("cancel-response", teardown);
3328
req.metadata?.on("close", teardown);

main.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1-
#!/usr/bin/env -S deno run --allow-read --allow-net --allow-env --allow-run --allow-hrtime --no-check --watch
2-
31
/// <reference no-default-lib="true" />
42
/// <reference lib="dom" />
53
/// <reference lib="dom.asynciterable" />
64
/// <reference lib="deno.ns" />
75
/// <reference lib="deno.unstable" />
86

9-
import { start } from "./server_deps.ts";
10-
import manifest from "./fresh.gen.ts";
7+
import { start } from "$fresh/server.ts";
8+
import { setup } from "@twind";
9+
import * as colors from "twind/colors";
10+
import { virtualSheet } from "twind/sheets";
11+
12+
import routes from "./fresh.gen.ts";
13+
14+
const sheet = virtualSheet();
15+
sheet.reset();
16+
setup({ sheet, theme: { colors } });
1117

12-
await start(manifest);
18+
await start(routes, {
19+
render(ctx, render) {
20+
const snapshot = ctx.state.get("twindSnapshot") as unknown[] | null;
21+
sheet.reset(snapshot || undefined);
22+
render();
23+
ctx.styles.splice(0, ctx.styles.length, ...sheet.target);
24+
const newSnapshot = sheet.reset();
25+
ctx.state.set("twindSnapshot", newSnapshot);
26+
},
27+
});

routes/_render.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

routes/docs/[...slug].tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/** @jsx h */
22
/** @jsxFrag Fragment */
33

4-
import { apply, Fragment, h, Head, PageProps, tw } from "../../client_deps.ts";
5-
import { gfm, Handlers } from "../../server_deps.ts";
4+
import { Fragment, h } from "preact";
5+
import { Head } from "$fresh/runtime.ts";
6+
import { Handlers, PageProps } from "$fresh/server.ts";
7+
import { apply, tw } from "@twind";
8+
import { gfm } from "@markdown";
69
import DocsSidebar from "../../components/DocsSidebar.tsx";
710
import Footer from "../../components/Footer.tsx";
811
import NavigationBar from "../../components/Navbar.tsx";

routes/gfm.css.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { gfm, Handlers } from "../server_deps.ts";
1+
import { gfm } from "@markdown";
2+
import { Handlers } from "$fresh/server.ts";
23

34
const CSS = `${gfm.CSS}
45

routes/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/** @jsx h */
22
/** @jsxFrag Fragment */
33

4-
import { Fragment, h, Head, tw } from "../client_deps.ts";
4+
import { Fragment, h } from "preact";
5+
import { Head } from "$fresh/runtime.ts";
6+
import { tw } from "@twind";
57
import NavigationBar from "../components/Navbar.tsx";
68
import Footer from "../components/Footer.tsx";
79

routes/wrp-example-guest.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @jsx h */
2-
import { h } from "../client_deps.ts";
2+
import { h } from "preact";
33
import WrpExampleGuest from "../islands/WrpExampleGuest.tsx";
44

55
export default function Page() {

routes/wrp-example-host.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @jsx h */
2-
import { h } from "../client_deps.ts";
2+
import { h } from "preact";
33
import WrpExampleHost from "../islands/WrpExampleHost.tsx";
44

55
export default function Page() {

routes/wrp-example.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @jsx h */
2-
import { h } from "../client_deps.ts";
2+
import { h } from "preact";
33
import WrpExample from "../islands/WrpExample.tsx";
44

55
export default function Page() {

routes/wrp-iframe-host.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @jsx h */
2-
import { h } from "../client_deps.ts";
2+
import { h } from "preact";
33
import WrpIframeHost from "../islands/WrpIframeHost.tsx";
44

55
export default function Page() {

server_deps.ts renamed to utils/markdown.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
export * from "https://raw.githubusercontent.com/lucacasonato/fresh/80598d07fd4eed735ea7ee3eb9728d7f5c9b3aa4/server.ts";
2-
3-
export { virtualSheet } from "https://esm.sh/twind@0.16.16/sheets";
4-
51
export * as gfm from "https://deno.land/x/gfm@0.1.19/mod.ts";
62
import "https://esm.sh/prismjs@1.27.0/components/prism-jsx.js?no-check";
73
import "https://esm.sh/prismjs@1.27.0/components/prism-typescript.js?no-check";

utils/preact-deps.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export * from "https://esm.sh/preact@10.8.1";
2+
export { jsx, jsxDEV, jsxs } from "https://esm.sh/preact@10.8.1/jsx-runtime";
3+
export {
4+
useCallback,
5+
useContext,
6+
useDebugValue,
7+
useEffect,
8+
useErrorBoundary,
9+
useImperativeHandle,
10+
useLayoutEffect,
11+
useMemo,
12+
useReducer,
13+
useRef,
14+
useState,
15+
} from "https://esm.sh/preact@10.8.1/hooks";
16+
export type {
17+
CreateHandle,
18+
EffectCallback,
19+
Inputs,
20+
PropRef,
21+
Reducer,
22+
Ref,
23+
StateUpdater,
24+
} from "https://esm.sh/preact@10.8.1/hooks";

0 commit comments

Comments
 (0)