Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
chore: update fresh (#2190)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato authored Jun 22, 2022
1 parent c750a6a commit 210d57c
Show file tree
Hide file tree
Showing 44 changed files with 159 additions and 118 deletions.
2 changes: 1 addition & 1 deletion components/BenchmarkChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h } from "$fresh/runtime.ts";
import { Fragment, h } from "preact";

import { Column, formatLogScale, logScale } from "@/util/benchmark_utils.ts";

Expand Down
3 changes: 2 additions & 1 deletion components/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { h } from "$fresh/runtime.ts";
import { h } from "preact";

import { tw } from "@twind";
import { Prism } from "@/util/prism_utils.ts";
import { escape as htmlEscape } from "$he";
Expand Down
4 changes: 3 additions & 1 deletion components/DirectoryView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { h } from "$fresh/runtime.ts";
import { h } from "preact";
import { tw } from "@twind";
import { DirListing, Entry, isReadme } from "@/util/registry_utils.ts";
import * as Icons from "@/components/Icons.tsx";
Expand Down
2 changes: 1 addition & 1 deletion components/ErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { ComponentChildren, h } from "$fresh/runtime.ts";
import { ComponentChildren, h } from "preact";
import { tw } from "@twind";
import * as Icons from "./Icons.tsx";

Expand Down
2 changes: 1 addition & 1 deletion components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { ComponentChildren, h } from "$fresh/runtime.ts";
import { ComponentChildren, h } from "preact";
import { tw } from "@twind";
import * as Icons from "./Icons.tsx";

Expand Down
3 changes: 2 additions & 1 deletion components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { h } from "$fresh/runtime.ts";
import { h } from "preact";

import { tw } from "@twind";
import * as Icons from "./Icons.tsx";

Expand Down
2 changes: 1 addition & 1 deletion components/HelloBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { ComponentChildren, h } from "$fresh/runtime.ts";
import { ComponentChildren, h } from "preact";
import { tw } from "@twind";

export function HelloBar(props: {
Expand Down
2 changes: 1 addition & 1 deletion components/HeroBackground.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Deno Land Inc. All Rights Reserved. Proprietary and confidential.

/** @jsx h */
import { h } from "$fresh/runtime.ts";
import { h } from "preact";
import { tw } from "@twind";

export function Background() {
Expand Down
2 changes: 1 addition & 1 deletion components/Icons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @jsx h */
import { h } from "$fresh/runtime.ts";
import { h } from "preact";
import { tw } from "@twind";

export function GitHub(props: { class?: string }) {
Expand Down
2 changes: 1 addition & 1 deletion components/InlineCode.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { ComponentChildren, h } from "$fresh/runtime.ts";
import { ComponentChildren, h } from "preact";
import { tw } from "@twind";

export function InlineCode(
Expand Down
2 changes: 1 addition & 1 deletion components/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { h } from "$fresh/runtime.ts";
import { h } from "preact";
import { tw } from "@twind";
import { render } from "$gfm";

Expand Down
2 changes: 1 addition & 1 deletion components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/** @jsx h */
/** @jsxFrag Fragment */
import { ComponentProps, Fragment, h } from "$fresh/runtime.ts";
import { ComponentProps, Fragment, h } from "preact";
import { tw } from "@twind";
import { PaginationProps } from "@/util/pagination_utils.ts";
import { SearchResult } from "@/util/registry_utils.ts";
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tasks": {
"dev": "deno run --watch --no-check --allow-read --allow-write --allow-run --allow-env --allow-net main.ts"
"start": "deno run -A --watch=routes/,static/ dev.ts"
},
"compilerOptions": {
"types": [
Expand Down
5 changes: 5 additions & 0 deletions dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/

import dev from "$fresh/dev.ts";

await dev(import.meta.url, "./main.ts");
74 changes: 36 additions & 38 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
// DO NOT EDIT. This file is generated by `fresh`.
// DO NOT EDIT. This file is generated by fresh.
// This file SHOULD be checked into source version control.
// To update this file, run `fresh manifest`.
// This file is automatically updated during development when running `dev.ts`.

import * as $0 from "./routes/_404.tsx";
import * as $1 from "./routes/_app.tsx";
import * as $2 from "./routes/_render.ts";
import * as $3 from "./routes/add_module.tsx";
import * as $4 from "./routes/artwork.tsx";
import * as $5 from "./routes/benchmarks.tsx";
import * as $6 from "./routes/completions/config.ts";
import * as $7 from "./routes/completions/v1.ts";
import * as $8 from "./routes/gfm.css.ts";
import * as $9 from "./routes/index.tsx";
import * as $10 from "./routes/install.ts";
import * as $11 from "./routes/legacy_redirects/posts.ts";
import * as $12 from "./routes/legacy_redirects/v1.ts";
import * as $13 from "./routes/manual.tsx";
import * as $14 from "./routes/showcase.tsx";
import * as $15 from "./routes/status.tsx";
import * as $16 from "./routes/std.tsx";
import * as $17 from "./routes/translations.tsx";
import * as $18 from "./routes/x/index.tsx";
import * as $19 from "./routes/x/module.tsx";
import * as $2 from "./routes/add_module.tsx";
import * as $3 from "./routes/artwork.tsx";
import * as $4 from "./routes/benchmarks.tsx";
import * as $5 from "./routes/completions/config.ts";
import * as $6 from "./routes/completions/v1.ts";
import * as $7 from "./routes/gfm.css.ts";
import * as $8 from "./routes/index.tsx";
import * as $9 from "./routes/install.ts";
import * as $10 from "./routes/legacy_redirects/posts.ts";
import * as $11 from "./routes/legacy_redirects/v1.ts";
import * as $12 from "./routes/manual.tsx";
import * as $13 from "./routes/showcase.tsx";
import * as $14 from "./routes/status.tsx";
import * as $15 from "./routes/std.tsx";
import * as $16 from "./routes/translations.tsx";
import * as $17 from "./routes/x/index.tsx";
import * as $18 from "./routes/x/module.tsx";
import * as $$0 from "./islands/VersionSelect.tsx";

const manifest = {
routes: {
"./routes/_404.tsx": $0,
"./routes/_app.tsx": $1,
"./routes/_render.ts": $2,
"./routes/add_module.tsx": $3,
"./routes/artwork.tsx": $4,
"./routes/benchmarks.tsx": $5,
"./routes/completions/config.ts": $6,
"./routes/completions/v1.ts": $7,
"./routes/gfm.css.ts": $8,
"./routes/index.tsx": $9,
"./routes/install.ts": $10,
"./routes/legacy_redirects/posts.ts": $11,
"./routes/legacy_redirects/v1.ts": $12,
"./routes/manual.tsx": $13,
"./routes/showcase.tsx": $14,
"./routes/status.tsx": $15,
"./routes/std.tsx": $16,
"./routes/translations.tsx": $17,
"./routes/x/index.tsx": $18,
"./routes/x/module.tsx": $19,
"./routes/add_module.tsx": $2,
"./routes/artwork.tsx": $3,
"./routes/benchmarks.tsx": $4,
"./routes/completions/config.ts": $5,
"./routes/completions/v1.ts": $6,
"./routes/gfm.css.ts": $7,
"./routes/index.tsx": $8,
"./routes/install.ts": $9,
"./routes/legacy_redirects/posts.ts": $10,
"./routes/legacy_redirects/v1.ts": $11,
"./routes/manual.tsx": $12,
"./routes/showcase.tsx": $13,
"./routes/status.tsx": $14,
"./routes/std.tsx": $15,
"./routes/translations.tsx": $16,
"./routes/x/index.tsx": $17,
"./routes/x/module.tsx": $18,
},
islands: {
"./islands/VersionSelect.tsx": $$0,
Expand Down
12 changes: 8 additions & 4 deletions import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"@/": "./",
"@twind": "./util/twind.ts",

"$fresh/": "https://raw.githubusercontent.com/lucacasonato/fresh/4bb07f4bcebfc205692e53bb61a1e2447d589c8e/",
"twind": "https://esm.sh/[email protected]",
"twind/": "https://esm.sh/[email protected]/",
"$fresh/": "https://deno.land/x/[email protected]/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"preact-render-to-string": "https://esm.sh/[email protected][email protected]",
"twind": "https://esm.sh/[email protected]",
"twind/": "https://esm.sh/[email protected]/",
"$prism": "https://esm.sh/[email protected]",
"$prism/": "https://esm.sh/[email protected]/",
"$twas": "https://esm.sh/[email protected]",
Expand All @@ -20,6 +23,7 @@
"$ga4": "https://raw.githubusercontent.com/denoland/ga4/main/mod.ts",
"$ga": "https://deno.land/x/[email protected]/mod.ts",
"$oak_commons": "https://deno.land/x/[email protected]/negotiation.ts",
"$doc_components/": "https://deno.land/x/[email protected]/"
"$doc_components/": "https://deno.land/x/[email protected]/",
"$deno_doc/": "https://deno.land/x/[email protected]/lib/"
}
}
5 changes: 4 additions & 1 deletion islands/VersionSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { h, IS_BROWSER } from "$fresh/runtime.ts";
import { h } from "preact";
import { IS_BROWSER } from "$fresh/runtime.ts";
import { tw } from "@twind";

export default function VersionSelect({ versions, selectedVersion }: {
Expand Down
5 changes: 3 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
/// <reference lib="deno.unstable" />

import { ServerContext } from "$fresh/server.ts";
import { Fragment, h } from "$fresh/runtime.ts";
import { Fragment, h } from "preact";
import { serve } from "$std/http/server.ts";
import { router } from "$router";
import { withLog } from "./util/ga_utils.ts";
import { setup } from "$doc_components/services.ts";

import manifest from "./fresh.gen.ts";
import options from "./options.ts";

import { routes as completionsV2Routes } from "./completions_v2.ts";

Expand Down Expand Up @@ -44,7 +45,7 @@ await setup({
runtime: { Fragment, h },
});

const ctx = await ServerContext.fromManifest(manifest);
const ctx = await ServerContext.fromManifest(manifest, options);

const innerHandler = withLog(ctx.handler());
const handler = router(completionsV2Routes, innerHandler);
Expand Down
22 changes: 22 additions & 0 deletions options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {
FreshOptions,
InnerRenderFunction,
RenderContext,
} from "$fresh/server.ts";
import { config, setup } from "@twind";
import { virtualSheet } from "twind/sheets";

const sheet = virtualSheet();
sheet.reset();
setup({ ...config, sheet });

function render(ctx: RenderContext, render: InnerRenderFunction) {
const snapshot = ctx.state.get("twind") as unknown[] | null;
sheet.reset(snapshot || undefined);
render();
ctx.styles.splice(0, ctx.styles.length, ...(sheet).target);
const newSnapshot = sheet.reset();
ctx.state.set("twind", newSnapshot);
}

export default { render } as FreshOptions;
3 changes: 2 additions & 1 deletion routes/_404.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

/** @jsx h */
import { h, Head } from "$fresh/runtime.ts";
import { h } from "preact";
import { Head } from "$fresh/runtime.ts";
import { tw } from "@twind";
import { Header } from "@/components/Header.tsx";
import { Footer } from "@/components/Footer.tsx";
Expand Down
4 changes: 3 additions & 1 deletion routes/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

/** @jsx h */
/** @jsxFrag Fragment */
import { AppProps, h, Head } from "$fresh/runtime.ts";
import { h } from "preact";
import { AppProps } from "$fresh/server.ts";
import { Head } from "$fresh/runtime.ts";
import { tw } from "@twind";

export default function App({ Component }: AppProps) {
Expand Down
18 changes: 0 additions & 18 deletions routes/_render.ts

This file was deleted.

3 changes: 2 additions & 1 deletion routes/add_module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

/** @jsx h */
/** @jsxFrag Fragment */
import { ComponentChildren, Fragment, h, Head } from "$fresh/runtime.ts";
import { Fragment, h } from "preact";
import { Head } from "$fresh/runtime.ts";
import { tw } from "@twind";
import { CDN_ENDPOINT } from "@/util/registry_utils.ts";
import { Header } from "@/components/Header.tsx";
Expand Down
3 changes: 2 additions & 1 deletion routes/artwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h, Head } from "$fresh/runtime.ts";
import { Fragment, h } from "preact";
import { Head } from "$fresh/runtime.ts";
import { tw } from "@twind";
import { Footer } from "@/components/Footer.tsx";
import { Header } from "@/components/Header.tsx";
Expand Down
4 changes: 3 additions & 1 deletion routes/benchmarks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h, Head, PageProps } from "$fresh/runtime.ts";
import { Fragment, h } from "preact";
import { PageProps } from "$fresh/server.ts";
import { Head } from "$fresh/runtime.ts";
import { tw } from "@twind";
import { Handlers } from "$fresh/server.ts";
import { Header } from "@/components/Header.tsx";
Expand Down
2 changes: 1 addition & 1 deletion routes/completions/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

import { RouteConfig } from "$fresh/runtime.ts";
import { RouteConfig } from "$fresh/server.ts";
import { accepts } from "$oak_commons";

interface RegistryDefVariable {
Expand Down
2 changes: 1 addition & 1 deletion routes/completions/v1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2022 the Deno authors. All rights reserved. MIT license.

import { RouteConfig } from "$fresh/runtime.ts";
import { RouteConfig } from "$fresh/server.ts";

export function handler(_req: Request) {
return new Response(
Expand Down
4 changes: 2 additions & 2 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h, Head } from "$fresh/runtime.ts";
import { Fragment, h } from "preact";
import { Head } from "$fresh/runtime.ts";
import { tw } from "@twind";
import { CodeBlock } from "@/components/CodeBlock.tsx";
import { Footer } from "@/components/Footer.tsx";
import { InlineCode } from "@/components/InlineCode.tsx";
import { Header } from "@/components/Header.tsx";
import { HelloBar } from "@/components/HelloBar.tsx";
import { Background } from "@/components/HeroBackground.tsx";
import * as Icons from "@/components/Icons.tsx";

import versions from "@/versions.json" assert { type: "json" };

Expand Down
Loading

0 comments on commit 210d57c

Please sign in to comment.