From 9079e8f4abacb9959d67ba6fb36dde79561011b0 Mon Sep 17 00:00:00 2001 From: Mark Gibson Date: Wed, 3 Apr 2024 16:36:53 +0100 Subject: [PATCH] Update deps Remove obsolete auth widget Start using cross platform libs --- .gitignore | 1 + cache/blog/dependency_hell | 2 +- cache/blog/http_fns | 2 +- cache/blog/jsx_streaming | 2 +- cache/index.html | 2 +- components/Delayed.tsx | 2 +- components/Markdown.tsx | 4 +- components/Page.tsx | 4 +- components/Trickled.tsx | 4 +- components/UserWidget.tsx | 95 ----------- config_fragment.ts | 2 +- config_page.ts | 2 +- deno.json | 31 ++-- deno.lock | 229 ++++++++++++++++++++------- import_map_deploy.json | 14 +- import_map_sw.json | 8 +- lib/handle_fragment.ts | 2 +- lib/handle_page.ts | 2 +- lib/oauth_config.ts | 77 --------- lib/oauth_providers.ts | 3 - lib/render_html.tsx | 6 +- lib/tag_hooks/github_elements.ts | 2 +- lib/tag_hooks/inject.tsx | 2 +- lib/tag_hooks/material_design.ts | 2 +- lib/tag_hooks/patternfly_elements.ts | 2 +- lib/tag_hooks/shoelace.ts | 2 +- lib/tag_hooks/vaadin.ts | 2 +- lib/tag_hooks/wired_elements.ts | 2 +- routes.ts | 6 +- routes/_static/sw.js | 22 +-- routes/_static/sw_compat.js | 22 +-- routes/auth/:provider/callback.ts | 14 -- routes/auth/:provider/signin.ts | 8 - routes/auth/_lib/oauth_config.ts | 32 ---- routes/auth/signout.ts | 6 - routes/auth/widget.tsx | 6 - routes/quote/_lib/quote_config.ts | 12 +- routes/quote/tv.ts | 2 +- routes/sse/feed.tsx | 4 +- scripts/build.ts | 2 +- 40 files changed, 258 insertions(+), 386 deletions(-) delete mode 100644 components/UserWidget.tsx delete mode 100644 lib/oauth_config.ts delete mode 100644 lib/oauth_providers.ts delete mode 100644 routes/auth/:provider/callback.ts delete mode 100644 routes/auth/:provider/signin.ts delete mode 100644 routes/auth/_lib/oauth_config.ts delete mode 100644 routes/auth/signout.ts delete mode 100644 routes/auth/widget.tsx diff --git a/.gitignore b/.gitignore index bd166a6..8a38f6f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .store .env +.env.* *.pem diff --git a/cache/blog/dependency_hell b/cache/blog/dependency_hell index 8617c6d..e6bec85 100644 --- a/cache/blog/dependency_hell +++ b/cache/blog/dependency_hell @@ -1,5 +1,5 @@ -Jollytoad

The home of Jollytoad

Dependency Hell or Heaven

+Jollytoad

The home of Jollytoad

Dependency Hell or Heaven

TLDR; Is Deno heading down the same dependency hell path as Node, due to the use of the deps.ts & mod.ts conventions?

Introduction

diff --git a/cache/blog/http_fns b/cache/blog/http_fns index f12c269..3308504 100644 --- a/cache/blog/http_fns +++ b/cache/blog/http_fns @@ -1,5 +1,5 @@ -Jollytoad

The home of Jollytoad

Useful functions for a HTTP server

+Jollytoad

The home of Jollytoad

Useful functions for a HTTP server

I've always considered HTTP to be a function, Request in, Response out.

I've never really warmed to the way Node frameworks such as Express, Koa, and henceforth Oak deal with it via middleware routers.

diff --git a/cache/blog/jsx_streaming b/cache/blog/jsx_streaming index 39aed45..339b78b 100644 --- a/cache/blog/jsx_streaming +++ b/cache/blog/jsx_streaming @@ -1,5 +1,5 @@ -Jollytoad

The home of Jollytoad

JSX Streaming

+Jollytoad

The home of Jollytoad

JSX Streaming

TLDR; This is about using JSX as an async streaming template language in Deno, and has very little to do with React.

Introduction

diff --git a/cache/index.html b/cache/index.html index 1c9dfe3..ad182ca 100644 --- a/cache/index.html +++ b/cache/index.html @@ -1,5 +1,5 @@ -Jollytoad

The home of Jollytoad

Demos and Experiments

+Jollytoad

The home of Jollytoad

Demos and Experiments

  • Quiz
  • Async component streaming demo
  • diff --git a/components/Delayed.tsx b/components/Delayed.tsx index 5c2a5ea..863b3f3 100644 --- a/components/Delayed.tsx +++ b/components/Delayed.tsx @@ -1,4 +1,4 @@ -import type { Children } from "$jsx/types"; +import type { Children } from "@http/jsx-stream/types"; import { delay } from "@std/async/delay"; export interface DelayedProps { diff --git a/components/Markdown.tsx b/components/Markdown.tsx index 02e38bd..464767e 100644 --- a/components/Markdown.tsx +++ b/components/Markdown.tsx @@ -4,9 +4,9 @@ import { gfmFromMarkdown } from "mdast-util-gfm"; import { toHast } from "mdast-util-to-hast"; import { type Options, toJsxRuntime } from "hast-util-to-jsx-runtime"; import { raw } from "hast-util-raw"; -import { Fragment, jsx, jsxDEV, jsxs } from "$jsx/jsx-runtime"; +import { Fragment, jsx, jsxDEV, jsxs } from "@http/jsx-stream/jsx-runtime"; import { fetchContent } from "../lib/content.ts"; -import type { Promisable } from "$jsx/types"; +import type { Promisable } from "@http/jsx-stream/types"; interface Props { url?: string; diff --git a/components/Page.tsx b/components/Page.tsx index 6bbcd8a..a7a3c23 100644 --- a/components/Page.tsx +++ b/components/Page.tsx @@ -1,6 +1,5 @@ -import type { Children } from "$jsx/types"; +import type { Children } from "@http/jsx-stream/types"; import { Src } from "../components/Src.tsx"; -import { UserWidget } from "../components/UserWidget.tsx"; import { getDeferredTimeout } from "../lib/deferred_timeout.ts"; interface Props { @@ -47,7 +46,6 @@ export function Page({ req, children, reqURL, module, ...props }: Props) {

    The home of Jollytoad

    -
    diff --git a/components/Trickled.tsx b/components/Trickled.tsx index 2e37eee..5904767 100644 --- a/components/Trickled.tsx +++ b/components/Trickled.tsx @@ -1,5 +1,5 @@ -import type { Children } from "$jsx/types"; -import { isAsyncIterable, isIterable } from "$jsx/guards"; +import type { Children } from "@http/jsx-stream/types"; +import { isAsyncIterable, isIterable } from "@http/jsx-stream/guards"; import { delay } from "@std/async/delay"; export interface TrickledProps { diff --git a/components/UserWidget.tsx b/components/UserWidget.tsx deleted file mode 100644 index 8f3510b..0000000 --- a/components/UserWidget.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import type { RequestProps } from "../lib/types.ts"; -import { getSessionId } from "$deno_kv_oauth/get_session_id.ts"; -import { - getOAuthClientNames, - hasOAuthClientEnvVars, -} from "../lib/oauth_config.ts"; - -export async function UserWidget( - { req, lazy }: Partial & { lazy?: boolean }, -) { - if (lazy) { - return ( -
    -
    - ); - } - - if (!req) { - return null; - } - - const sessionId = await getSessionId(req); - - if (sessionId) { - return ; - } else { - const providers = await getProviders(); - return ; - } -} - -function SignedIn({ sessionId }: { sessionId: string }) { - return ( -
    - Sign Out -
    - ); -} - -function SignedOut({ providers }: { providers: Provider[] }) { - switch (providers.length) { - case 0: - return null; - case 1: - return ( - - ); - default: - return ( -
    - - -
    - ); - } -} - -interface Provider { - id: string; - name: string; -} - -async function getProviders(): Promise { - return (await Promise.all( - getOAuthClientNames().map(async (name) => { - if (await hasOAuthClientEnvVars(name)) { - return { - id: name.toLowerCase(), - name, - }; - } - }), - )).filter((v): v is Provider => !!v); -} diff --git a/config_fragment.ts b/config_fragment.ts index 77c15bd..6b8e907 100644 --- a/config_fragment.ts +++ b/config_fragment.ts @@ -1,4 +1,4 @@ -import type { RenderOptions } from "$jsx/types"; +import type { RenderOptions } from "@http/jsx-stream/types"; export const FRAGMENT_RENDER_OPTIONS: RenderOptions = { deferredTimeout: false, diff --git a/config_page.ts b/config_page.ts index c28accd..f338b20 100644 --- a/config_page.ts +++ b/config_page.ts @@ -1,4 +1,4 @@ -import type { RenderOptions } from "$jsx/types"; +import type { RenderOptions } from "@http/jsx-stream/types"; import { materialDesignElements } from "./lib/tag_hooks/material_design.ts"; import { shoelaceElements } from "./lib/tag_hooks/shoelace.ts"; import { vaadinElements } from "./lib/tag_hooks/vaadin.ts"; diff --git a/deno.json b/deno.json index 17030b2..7fa8e24 100644 --- a/deno.json +++ b/deno.json @@ -13,11 +13,12 @@ "mkcert": "mkcert -install -key-file localhost-key.pem -cert-file localhost-cert.pem localhost", "deploy": "deno run --allow-sys --allow-net --allow-read --allow-write --allow-env jsr:@deno/deployctl deploy --import-map=import_map_deploy.json", "check": "deno fmt && deno lint && deno check **/*.ts", - "lock": "rm -f deno.lock && deno check **/*.ts" + "lock": "rm -f deno.lock && deno check **/*.ts", + "outdated": "deno run --allow-read=. --allow-net=jsr.io,registry.npmjs.org jsr:@check/deps" }, "compilerOptions": { "jsx": "react-jsx", - "jsxImportSource": "$jsx", + "jsxImportSource": "@http/jsx-stream", "verbatimModuleSyntax": true }, "exclude": [ @@ -32,26 +33,26 @@ ] }, "imports": { + "$jsx": "jsr:@http/jsx-stream@^0.1.1", + "$store": "https://deno.land/x/storage_modules@v0.1.0/deno_kv.ts", + "@cross/env": "jsr:@cross/env@^1.0.0", + "@http/fns": "jsr:@http/fns@^0.7.0", + "@http/jsx-stream": "jsr:@http/jsx-stream@^0.1.1", "@std/async": "jsr:@std/async@^0.219.1", - "@std/http": "jsr:@std/http@^0.219.1", "@std/collections": "jsr:@std/collections@^0.219.1", - "@std/path": "jsr:@std/path@^0.219.1", "@std/fs": "jsr:@std/fs@^0.219.1", + "@std/http": "jsr:@std/http@^0.219.1", + "@std/path": "jsr:@std/path@^0.219.1", "@std/ulid": "jsr:@std/ulid@^0.219.1", - "@http/fns": "jsr:@http/fns@^0.6.4", - "$jsx": "jsr:@http/jsx-stream@^0.1.1", - "$deno_kv_oauth/": "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/", - "https://deno.land/x/oauth2_client@v1.0.2/mod.ts": "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/mod.ts", - "$store": "https://deno.land/x/storage_modules@v0.1.0/deno_kv.ts", "esbuild": "npm:esbuild@0.20", - "esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@0.9", - "urlpattern-polyfill": "npm:urlpattern-polyfill@10.0.0", + "esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3", + "hast-util-raw": "npm:hast-util-raw@9.0.2", + "hast-util-to-jsx-runtime": "npm:hast-util-to-jsx-runtime@2.3.0", "mdast-util-from-markdown": "npm:mdast-util-from-markdown@2.0.0", - "micromark-extension-gfm": "npm:micromark-extension-gfm@3.0.0", "mdast-util-gfm": "npm:mdast-util-gfm@3.0.0", - "mdast-util-to-hast": "npm:mdast-util-to-hast@13.0.2", - "hast-util-to-jsx-runtime": "npm:hast-util-to-jsx-runtime@2.2.0", - "hast-util-raw": "npm:hast-util-raw@9.0.1" + "mdast-util-to-hast": "npm:mdast-util-to-hast@13.1.0", + "micromark-extension-gfm": "npm:micromark-extension-gfm@3.0.0", + "urlpattern-polyfill": "npm:urlpattern-polyfill@10.0.0" }, "deploy": { "project": "jollytoad", diff --git a/deno.lock b/deno.lock index 85eb3a8..3c6290c 100644 --- a/deno.lock +++ b/deno.lock @@ -2,11 +2,14 @@ "version": "3", "packages": { "specifiers": { + "jsr:@cross/deepmerge@^1.0.0": "jsr:@cross/deepmerge@1.0.0", + "jsr:@cross/env@^1.0.0": "jsr:@cross/env@1.0.0", + "jsr:@cross/runtime@^1.0.0": "jsr:@cross/runtime@1.0.0", "jsr:@http/fns@^0.6.3": "jsr:@http/fns@0.6.4", - "jsr:@http/fns@^0.6.4": "jsr:@http/fns@0.6.4", + "jsr:@http/fns@^0.7.0": "jsr:@http/fns@0.7.0", "jsr:@http/jsx-stream@0.1.1": "jsr:@http/jsx-stream@0.1.1", "jsr:@http/jsx-stream@^0.1.1": "jsr:@http/jsx-stream@0.1.1", - "jsr:@luca/esbuild-deno-loader@0.9": "jsr:@luca/esbuild-deno-loader@0.9.0", + "jsr:@luca/esbuild-deno-loader@^0.10.3": "jsr:@luca/esbuild-deno-loader@0.10.3", "jsr:@std/assert@^0.213.1": "jsr:@std/assert@0.213.1", "jsr:@std/assert@^0.219.1": "jsr:@std/assert@0.219.1", "jsr:@std/async@0.219": "jsr:@std/async@0.219.1", @@ -28,18 +31,34 @@ "jsr:@std/streams@^0.219.1": "jsr:@std/streams@0.219.1", "jsr:@std/ulid@^0.219.1": "jsr:@std/ulid@0.219.1", "npm:esbuild@0.20": "npm:esbuild@0.20.0", - "npm:hast-util-raw@9.0.1": "npm:hast-util-raw@9.0.1", - "npm:hast-util-to-jsx-runtime@2.2.0": "npm:hast-util-to-jsx-runtime@2.2.0", + "npm:hast-util-raw@9.0.2": "npm:hast-util-raw@9.0.2", + "npm:hast-util-to-jsx-runtime@2.3.0": "npm:hast-util-to-jsx-runtime@2.3.0", "npm:mdast-util-from-markdown@2.0.0": "npm:mdast-util-from-markdown@2.0.0", "npm:mdast-util-gfm@3.0.0": "npm:mdast-util-gfm@3.0.0", - "npm:mdast-util-to-hast@13.0.2": "npm:mdast-util-to-hast@13.0.2", + "npm:mdast-util-to-hast@13.1.0": "npm:mdast-util-to-hast@13.1.0", "npm:micromark-extension-gfm@3.0.0": "npm:micromark-extension-gfm@3.0.0", "npm:openai": "npm:openai@4.28.4", "npm:urlpattern-polyfill@10.0.0": "npm:urlpattern-polyfill@10.0.0" }, "jsr": { + "@cross/deepmerge@1.0.0": { + "integrity": "1e1318a74e31ba1959b9aa0acae8bd417b806f74ffd25ac07c90e12f83ad6b1d" + }, + "@cross/env@1.0.0": { + "integrity": "1007d5bd0181a6766fe37b40f2f8feffdb1ccc1c176dd96d9d006916388b2c3e", + "dependencies": [ + "jsr:@cross/deepmerge@^1.0.0", + "jsr:@cross/runtime@^1.0.0" + ] + }, + "@cross/runtime@1.0.0": { + "integrity": "dddecdf99182df13d50279d1e473f715e83d41961c5c22edd7bb0c4c3cf8a76a" + }, "@http/fns@0.6.4": { - "integrity": "660b4be935409ae0086e65508493585fcf89a7caf24b86b5eb5c74f9d8aae7b3", + "integrity": "660b4be935409ae0086e65508493585fcf89a7caf24b86b5eb5c74f9d8aae7b3" + }, + "@http/fns@0.7.0": { + "integrity": "a8d914e124d7b7308d8abca6e482d78b16b87ad976ca9aaad3aee38dd2edcb6e", "dependencies": [ "jsr:@std/http@^0.219.1", "jsr:@std/media-types@^0.219.1", @@ -54,13 +73,12 @@ "jsr:@std/html@0.219" ] }, - "@luca/esbuild-deno-loader@0.9.0": { - "integrity": "288bbcede5c8a6f97e635f8fa4df779b13440ee0c0506d9e478fb6537789dc93", + "@luca/esbuild-deno-loader@0.10.3": { + "integrity": "32fc93f7e7f78060234fd5929a740668aab1c742b808c6048b57f9aaea514921", "dependencies": [ "jsr:@std/encoding@0.213", "jsr:@std/jsonc@0.213", - "jsr:@std/path@0.213", - "npm:esbuild@0.20" + "jsr:@std/path@0.213" ] }, "@std/assert@0.213.1": { @@ -242,6 +260,16 @@ "@types/ms": "@types/ms@0.7.34" } }, + "@types/estree-jsx@1.0.5": { + "integrity": "sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==", + "dependencies": { + "@types/estree": "@types/estree@1.0.5" + } + }, + "@types/estree@1.0.5": { + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dependencies": {} + }, "@types/hast@3.0.4": { "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", "dependencies": { @@ -275,6 +303,10 @@ "undici-types": "undici-types@5.26.5" } }, + "@types/unist@2.0.10": { + "integrity": "sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==", + "dependencies": {} + }, "@types/unist@3.0.2": { "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==", "dependencies": {} @@ -307,10 +339,22 @@ "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", "dependencies": {} }, + "character-entities-html4@2.1.0": { + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "dependencies": {} + }, + "character-entities-legacy@3.0.0": { + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "dependencies": {} + }, "character-entities@2.0.2": { "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", "dependencies": {} }, + "character-reference-invalid@2.0.1": { + "integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==", + "dependencies": {} + }, "charenc@0.0.2": { "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", "dependencies": {} @@ -398,6 +442,10 @@ "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", "dependencies": {} }, + "estree-util-is-identifier-name@3.0.0": { + "integrity": "sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==", + "dependencies": {} + }, "event-target-shim@5.0.1": { "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", "dependencies": {} @@ -440,8 +488,8 @@ "@types/hast": "@types/hast@3.0.4" } }, - "hast-util-raw@9.0.1": { - "integrity": "sha512-5m1gmba658Q+lO5uqL5YNGQWeh1MYWZbZmWrM5lncdcuiXuo5E2HT/CIOp0rLF8ksfSwiCVJ3twlgVRyTGThGA==", + "hast-util-raw@9.0.2": { + "integrity": "sha512-PldBy71wO9Uq1kyaMch9AHIghtQvIwxBUkv823pKmkTM3oV1JxtsTNYdevMxvUHqcnOAuO65JKU2+0NOxc2ksA==", "dependencies": { "@types/hast": "@types/hast@3.0.4", "@types/unist": "@types/unist@3.0.2", @@ -449,7 +497,7 @@ "hast-util-from-parse5": "hast-util-from-parse5@8.0.1", "hast-util-to-parse5": "hast-util-to-parse5@8.0.0", "html-void-elements": "html-void-elements@3.0.0", - "mdast-util-to-hast": "mdast-util-to-hast@13.0.2", + "mdast-util-to-hast": "mdast-util-to-hast@13.1.0", "parse5": "parse5@7.1.2", "unist-util-position": "unist-util-position@5.0.0", "unist-util-visit": "unist-util-visit@5.0.0", @@ -458,16 +506,22 @@ "zwitch": "zwitch@2.0.4" } }, - "hast-util-to-jsx-runtime@2.2.0": { - "integrity": "sha512-wSlp23N45CMjDg/BPW8zvhEi3R+8eRE1qFbjEyAUzMCzu2l1Wzwakq+Tlia9nkCtEl5mDxa7nKHsvYJ6Gfn21A==", + "hast-util-to-jsx-runtime@2.3.0": { + "integrity": "sha512-H/y0+IWPdsLLS738P8tDnrQ8Z+dj12zQQ6WC11TIM21C8WFVoIxcqWXf2H3hiTVZjF1AWqoimGwrTWecWrnmRQ==", "dependencies": { + "@types/estree": "@types/estree@1.0.5", "@types/hast": "@types/hast@3.0.4", "@types/unist": "@types/unist@3.0.2", "comma-separated-tokens": "comma-separated-tokens@2.0.3", + "devlop": "devlop@1.1.0", + "estree-util-is-identifier-name": "estree-util-is-identifier-name@3.0.0", "hast-util-whitespace": "hast-util-whitespace@3.0.0", + "mdast-util-mdx-expression": "mdast-util-mdx-expression@2.0.0", + "mdast-util-mdx-jsx": "mdast-util-mdx-jsx@3.1.2", + "mdast-util-mdxjs-esm": "mdast-util-mdxjs-esm@2.0.1", "property-information": "property-information@6.4.1", "space-separated-tokens": "space-separated-tokens@2.0.2", - "style-to-object": "style-to-object@0.4.4", + "style-to-object": "style-to-object@1.0.5", "unist-util-position": "unist-util-position@5.0.0", "vfile-message": "vfile-message@4.0.2" } @@ -510,14 +564,33 @@ "ms": "ms@2.1.3" } }, - "inline-style-parser@0.1.1": { - "integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==", + "inline-style-parser@0.2.2": { + "integrity": "sha512-EcKzdTHVe8wFVOGEYXiW9WmJXPjqi1T+234YpJr98RiFYKHV3cdy1+3mkTE+KHTHxFFLH51SfaGOoUdW+v7ViQ==", + "dependencies": {} + }, + "is-alphabetical@2.0.1": { + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", "dependencies": {} }, + "is-alphanumerical@2.0.1": { + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "dependencies": { + "is-alphabetical": "is-alphabetical@2.0.1", + "is-decimal": "is-decimal@2.0.1" + } + }, "is-buffer@1.1.6": { "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dependencies": {} }, + "is-decimal@2.0.1": { + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "dependencies": {} + }, + "is-hexadecimal@2.0.1": { + "integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==", + "dependencies": {} + }, "longest-streak@3.1.0": { "integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==", "dependencies": {} @@ -619,6 +692,46 @@ "mdast-util-to-markdown": "mdast-util-to-markdown@2.1.0" } }, + "mdast-util-mdx-expression@2.0.0": { + "integrity": "sha512-fGCu8eWdKUKNu5mohVGkhBXCXGnOTLuFqOvGMvdikr+J1w7lDJgxThOKpwRWzzbyXAU2hhSwsmssOY4yTokluw==", + "dependencies": { + "@types/estree-jsx": "@types/estree-jsx@1.0.5", + "@types/hast": "@types/hast@3.0.4", + "@types/mdast": "@types/mdast@4.0.3", + "devlop": "devlop@1.1.0", + "mdast-util-from-markdown": "mdast-util-from-markdown@2.0.0", + "mdast-util-to-markdown": "mdast-util-to-markdown@2.1.0" + } + }, + "mdast-util-mdx-jsx@3.1.2": { + "integrity": "sha512-eKMQDeywY2wlHc97k5eD8VC+9ASMjN8ItEZQNGwJ6E0XWKiW/Z0V5/H8pvoXUf+y+Mj0VIgeRRbujBmFn4FTyA==", + "dependencies": { + "@types/estree-jsx": "@types/estree-jsx@1.0.5", + "@types/hast": "@types/hast@3.0.4", + "@types/mdast": "@types/mdast@4.0.3", + "@types/unist": "@types/unist@3.0.2", + "ccount": "ccount@2.0.1", + "devlop": "devlop@1.1.0", + "mdast-util-from-markdown": "mdast-util-from-markdown@2.0.0", + "mdast-util-to-markdown": "mdast-util-to-markdown@2.1.0", + "parse-entities": "parse-entities@4.0.1", + "stringify-entities": "stringify-entities@4.0.4", + "unist-util-remove-position": "unist-util-remove-position@5.0.0", + "unist-util-stringify-position": "unist-util-stringify-position@4.0.0", + "vfile-message": "vfile-message@4.0.2" + } + }, + "mdast-util-mdxjs-esm@2.0.1": { + "integrity": "sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==", + "dependencies": { + "@types/estree-jsx": "@types/estree-jsx@1.0.5", + "@types/hast": "@types/hast@3.0.4", + "@types/mdast": "@types/mdast@4.0.3", + "devlop": "devlop@1.1.0", + "mdast-util-from-markdown": "mdast-util-from-markdown@2.0.0", + "mdast-util-to-markdown": "mdast-util-to-markdown@2.1.0" + } + }, "mdast-util-phrasing@4.1.0": { "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", "dependencies": { @@ -626,8 +739,8 @@ "unist-util-is": "unist-util-is@6.0.0" } }, - "mdast-util-to-hast@13.0.2": { - "integrity": "sha512-U5I+500EOOw9e3ZrclN3Is3fRpw8c19SMyNZlZ2IS+7vLsNzb2Om11VpIVOR+/0137GhZsFEF6YiKD5+0Hr2Og==", + "mdast-util-to-hast@13.1.0": { + "integrity": "sha512-/e2l/6+OdGp/FB+ctrJ9Avz71AN/GRH3oi/3KAx/kMnoUsD6q0woXlDT8lLEeViVKE7oZxE7RXzvO3T8kF2/sA==", "dependencies": { "@types/hast": "@types/hast@3.0.4", "@types/mdast": "@types/mdast@4.0.3", @@ -636,7 +749,8 @@ "micromark-util-sanitize-uri": "micromark-util-sanitize-uri@2.0.0", "trim-lines": "trim-lines@3.0.1", "unist-util-position": "unist-util-position@5.0.0", - "unist-util-visit": "unist-util-visit@5.0.0" + "unist-util-visit": "unist-util-visit@5.0.0", + "vfile": "vfile@6.0.1" } }, "mdast-util-to-markdown@2.1.0": { @@ -945,6 +1059,19 @@ "web-streams-polyfill": "web-streams-polyfill@3.3.3" } }, + "parse-entities@4.0.1": { + "integrity": "sha512-SWzvYcSJh4d/SGLIOQfZ/CoNv6BTlI6YEQ7Nj82oDVnRpwe/Z/F1EMx42x3JAOwGBlCjeCH0BRJQbQ/opHL17w==", + "dependencies": { + "@types/unist": "@types/unist@2.0.10", + "character-entities": "character-entities@2.0.2", + "character-entities-legacy": "character-entities-legacy@3.0.0", + "character-reference-invalid": "character-reference-invalid@2.0.1", + "decode-named-character-reference": "decode-named-character-reference@1.0.2", + "is-alphanumerical": "is-alphanumerical@2.0.1", + "is-decimal": "is-decimal@2.0.1", + "is-hexadecimal": "is-hexadecimal@2.0.1" + } + }, "parse5@7.1.2": { "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", "dependencies": { @@ -959,10 +1086,17 @@ "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", "dependencies": {} }, - "style-to-object@0.4.4": { - "integrity": "sha512-HYNoHZa2GorYNyqiCaBgsxvcJIn7OHq6inEga+E6Ke3m5JkoqpQbnFssk4jwe+K7AhGa2fcha4wSOf1Kn01dMg==", + "stringify-entities@4.0.4": { + "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", "dependencies": { - "inline-style-parser": "inline-style-parser@0.1.1" + "character-entities-html4": "character-entities-html4@2.1.0", + "character-entities-legacy": "character-entities-legacy@3.0.0" + } + }, + "style-to-object@1.0.5": { + "integrity": "sha512-rDRwHtoDD3UMMrmZ6BzOW0naTjMsVZLIjsGleSKS/0Oz+cgCfAPRspaqJuE8rDzpKha/nEvnM0IF4seEAZUTKQ==", + "dependencies": { + "inline-style-parser": "inline-style-parser@0.2.2" } }, "tr46@0.0.3": { @@ -989,6 +1123,13 @@ "@types/unist": "@types/unist@3.0.2" } }, + "unist-util-remove-position@5.0.0": { + "integrity": "sha512-Hp5Kh3wLxv0PHj9m2yZhhLt58KzPtEYKQQ4yxfYFEO7EvHwzyDYnduhHnY1mDxoqr7VUwVuHXk9RXKIiYS1N8Q==", + "dependencies": { + "@types/unist": "@types/unist@3.0.2", + "unist-util-visit": "unist-util-visit@5.0.0" + } + }, "unist-util-stringify-position@4.0.0": { "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", "dependencies": { @@ -1066,43 +1207,15 @@ } }, "remote": { - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/mod.ts": "ea54c0a894d3303a80552ca65835b5b104d16415343b24e191f08e7f5db90ff7", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/authorization_code_grant.ts": "36953750b75fb0a14fbf4e0e4bcc1d5ae0209d216d7b32f93a134b035ecf3d25", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/client_credentials_grant.ts": "5bb9869925c5f5d11e8d66a86da37e2353107d57f57ec3a1480e197462e79be5", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/errors.ts": "7603479b80386b5cc7e384c2af5f5262ed7c2123e4e297d9f21e95515f8a803a", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/grant_base.ts": "0e3bfb7d901d359ca89583f69520b723b9f54f8525815c843ad59cafa1c04ce2", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/implicit_grant.ts": "d5359aebbdaaff039c0d078890aa4ffa2869da19c521e535e15caf09c069e6b8", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/oauth2_client.ts": "4e5ec26676661a3f69544826a4c27b30cc07dfcfc77f86981c324aaa53291a11", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/pkce.ts": "d286a087cc8ef985b71a2bf391e9e9d86a78ac6d93e30c46e73006171aed0986", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/refresh_token_grant.ts": "22cb1598e48fb037b4111a446573f7b48a3b361b58de58af17ba097221b12b54", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/resource_owner_password_credentials.ts": "bd3df99d32eeebffb411c4a2d3c3d057395515fb41690a8d91460dd74b9bf466", - "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/src/types.ts": "4485e4d5fd945be127d3e0e54998eebd531fa69902e1f9283bf5482cc7fc2c69", - "https://deno.land/std@0.161.0/encoding/base64.ts": "c57868ca7fa2fbe919f57f88a623ad34e3d970d675bdc1ff3a9d02bba7409db2", - "https://deno.land/std@0.204.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", - "https://deno.land/std@0.204.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", - "https://deno.land/std@0.204.0/datetime/constants.ts": "b63a6b702e06fa028fb2ffa25e0cf775e3b21cf7f38e53a6f219e9641894dfbb", - "https://deno.land/std@0.204.0/http/cookie.ts": "c6079019fc15c781c302574f40fa2ac71c26b251e8f74eb236ea43e0424edcd7", - "https://deno.land/std@0.204.0/http/http_status.ts": "8a7bcfe3ac025199ad804075385e57f63d055b2aed539d943ccc277616d6f932", - "https://deno.land/x/deno_kv_oauth@v0.10.0/deps.ts": "34491a123e4a5c66f3e441fa04302220c6165db091650839243894d1dc74b30b", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/_http.ts": "d1a3d6153d574aae4011c3548acca938d91e2c160946fdd8ea502a2a37127613", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/_kv.ts": "77740f486e50591512a41d96674577adc0d8da632cc11e00c70b26234567a7e3", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/create_github_oauth_config.ts": "7969bcd95127bd1a85de10e0fd27a283ca55fa8042bcecf1ea002316f6e31ea5", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/create_google_oauth_config.ts": "ebe738ac30d765e9212553e0f0b7f36c7236338f9e9799f15790b4d04ffbd26c", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/create_okta_oauth_config.ts": "912b898aa6f9227dbad20ab9412e2e385248202dcced011c19ddd2a254f622d6", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/get_required_env.ts": "3ec1a1c1cf8eeb59009535e38a5636058bdca4528d8a3300750cbbef038ce863", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/get_session_id.ts": "8f56928c7e7905f75a11d05d6b08a5c75b17d77880532a0fd56b18c7ee723fd1", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/handle_callback.ts": "87b41660cc60a1387c08dd8e12890fbcf9d7543426871ef80d2a50aeb2afe667", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/sign_in.ts": "15f3978bd121ac107946aaea3d6325e0bb393c9f9f4e2f09f6f45072f9b9284f", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/sign_out.ts": "63a3fa8d975cedd644656766285e3ef0685cab21b2634fe9177c8c3af6faa97f", - "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/types.ts": "1f38ba43c3cbcee2999fa95478f8475fce53b01ef1d106b925cfc42c030c9f31", "https://deno.land/x/storage_modules@v0.1.0/deno_kv.ts": "61add7e4c9f59be67fa32569ec7618ecc22012da1cc729dc0f549b99d6444b35", "https://deno.land/x/storage_modules@v0.1.0/types.ts": "af64a15416106edf080877933d942b47a482ff8ad84a2ca3948c4af8050a6d56" }, "workspace": { "dependencies": [ - "jsr:@http/fns@^0.6.4", + "jsr:@cross/env@^1.0.0", + "jsr:@http/fns@^0.7.0", "jsr:@http/jsx-stream@^0.1.1", - "jsr:@luca/esbuild-deno-loader@0.9", + "jsr:@luca/esbuild-deno-loader@^0.10.3", "jsr:@std/async@^0.219.1", "jsr:@std/collections@^0.219.1", "jsr:@std/fs@^0.219.1", @@ -1110,11 +1223,11 @@ "jsr:@std/path@^0.219.1", "jsr:@std/ulid@^0.219.1", "npm:esbuild@0.20", - "npm:hast-util-raw@9.0.1", - "npm:hast-util-to-jsx-runtime@2.2.0", + "npm:hast-util-raw@9.0.2", + "npm:hast-util-to-jsx-runtime@2.3.0", "npm:mdast-util-from-markdown@2.0.0", "npm:mdast-util-gfm@3.0.0", - "npm:mdast-util-to-hast@13.0.2", + "npm:mdast-util-to-hast@13.1.0", "npm:micromark-extension-gfm@3.0.0", "npm:urlpattern-polyfill@10.0.0" ] diff --git a/import_map_deploy.json b/import_map_deploy.json index a4b2141..b7818cb 100644 --- a/import_map_deploy.json +++ b/import_map_deploy.json @@ -5,17 +5,15 @@ "@std/collections/": "jsr:/@std/collections@^0.219.1/", "@std/path/": "jsr:/@std/path@^0.219.1/", "@std/ulid": "jsr:@std/ulid@^0.219.1", - "@http/fns/": "jsr:/@http/fns@^0.6.3/", - "$jsx": "jsr:@http/jsx-stream@^0.1.1", - "$jsx/": "jsr:/@http/jsx-stream@^0.1.1/", - "$deno_kv_oauth/": "https://deno.land/x/deno_kv_oauth@v0.10.0/lib/", - "https://deno.land/x/oauth2_client@v1.0.2/mod.ts": "https://cdn.jsdelivr.net/gh/jollytoad/deno-oauth2-client@oidc-2/mod.ts", + "@http/fns/": "jsr:/@http/fns@^0.7.0/", + "@http/jsx-stream": "jsr:@http/jsx-stream@^0.1.1", + "@http/jsx-stream/": "jsr:/@http/jsx-stream@^0.1.1/", "$store": "https://deno.land/x/storage_modules@v0.1.0/deno_kv.ts", "mdast-util-from-markdown": "npm:mdast-util-from-markdown@2.0.0", "micromark-extension-gfm": "npm:micromark-extension-gfm@3.0.0", "mdast-util-gfm": "npm:mdast-util-gfm@3.0.0", - "mdast-util-to-hast": "npm:mdast-util-to-hast@13.0.2", - "hast-util-to-jsx-runtime": "npm:hast-util-to-jsx-runtime@2.2.0", - "hast-util-raw": "npm:hast-util-raw@9.0.1" + "mdast-util-to-hast": "npm:mdast-util-to-hast@13.1.0", + "hast-util-to-jsx-runtime": "npm:hast-util-to-jsx-runtime@2.3.0", + "hast-util-raw": "npm:hast-util-raw@9.0.2" } } diff --git a/import_map_sw.json b/import_map_sw.json index 32fc7f3..273c61c 100644 --- a/import_map_sw.json +++ b/import_map_sw.json @@ -1,9 +1,9 @@ { "imports": { - "@http/fns": "jsr:@http/fns@^0.6.3", - "@http/fns/": "jsr:/@http/fns@^0.6.3/", - "$jsx": "jsr:@http/jsx-stream@0.1.1", - "$jsx/": "jsr:/@http/jsx-stream@0.1.1/", + "@http/fns": "jsr:@http/fns@^0.7.0", + "@http/fns/": "jsr:/@http/fns@^0.7.0/", + "@http/jsx-stream": "jsr:@http/jsx-stream@0.1.1", + "@http/jsx-stream/": "jsr:/@http/jsx-stream@0.1.1/", "https://jsr.io/@http/jsx-stream/0.1.1/serialize.ts": "https://jsr.io/@http/jsx-stream/0.1.1/serialize_sw.ts", "urlpattern-polyfill": "npm:urlpattern-polyfill@10.0.0" } diff --git a/lib/handle_fragment.ts b/lib/handle_fragment.ts index 03f7132..cdc7228 100644 --- a/lib/handle_fragment.ts +++ b/lib/handle_fragment.ts @@ -1,6 +1,6 @@ import { byMethod } from "@http/fns/by_method"; import { FRAGMENT_RENDER_OPTIONS } from "../config_fragment.ts"; -import type { ComponentType } from "$jsx/types"; +import type { ComponentType } from "@http/jsx-stream/types"; import type { RouteProps } from "./types.ts"; import { renderHTML } from "./render_html.tsx"; diff --git a/lib/handle_page.ts b/lib/handle_page.ts index 1476051..7e46a00 100644 --- a/lib/handle_page.ts +++ b/lib/handle_page.ts @@ -1,5 +1,5 @@ import { byMethod } from "@http/fns/by_method"; -import type { ComponentType } from "$jsx/types"; +import type { ComponentType } from "@http/jsx-stream/types"; import type { RouteProps } from "./types.ts"; import { PAGE_RENDER_OPTIONS } from "../config_page.ts"; import { FRAGMENT_RENDER_OPTIONS } from "../config_fragment.ts"; diff --git a/lib/oauth_config.ts b/lib/oauth_config.ts deleted file mode 100644 index 7dcb63f..0000000 --- a/lib/oauth_config.ts +++ /dev/null @@ -1,77 +0,0 @@ -import * as providers from "./oauth_providers.ts"; -export type { OAuth2ClientConfig } from "$deno_kv_oauth/types.ts"; - -type Providers = typeof providers; -type ProviderFn = Providers[keyof Providers]; -type CreateClientFn = ( - config: Parameters[0], -) => ReturnType; - -/** - * Get a list of all supported OAuth client names - */ -export function getOAuthClientNames(): string[] { - const names: string[] = []; - - for (const [name, fn] of Object.entries(providers)) { - if (typeof fn === "function") { - const m = /^create(.*)OAuthConfig$/.exec(name); - if (m && m[1]) { - names.push(m[1]); - } - } - } - - return names; -} - -/** - * Detect whether environment vars have been set for a given OAuth client - */ -export async function hasOAuthClientEnvVars(name: string): Promise { - const upper = name.toUpperCase(); - const clientIdVar = `${upper}_CLIENT_ID`; - const clientSecretVar = `${upper}_CLIENT_SECRET`; - if ( - await Deno.permissions.query({ name: "env", variable: clientIdVar }) && - await Deno.permissions.query({ name: "env", variable: clientSecretVar }) - ) { - return Deno.env.has(clientIdVar) && Deno.env.has(clientSecretVar); - } else { - return false; - } -} - -/** - * Get the create config function for an OAuth client - * @param provider the name of the OAuth client - * @returns the OAuth config constructor function - */ -export function getOAuthConfigFn( - provider: string, -): CreateClientFn | undefined { - const providerFnName = `create${provider.toLowerCase()}oauthconfig`; - - for (const [name, fn] of Object.entries(providers)) { - if (typeof fn === "function") { - if (name.toLowerCase() === providerFnName) { - return fn as CreateClientFn; - } - } - } -} - -/** - * Get the OAuth scope for a provider from environment vars - * @param provider the name of the OAuth client - */ -export async function getOAuthClientScope( - provider: string, -): Promise { - const clientScopeVar = `${provider.toUpperCase()}_CLIENT_SCOPE`; - if ( - await Deno.permissions.query({ name: "env", variable: clientScopeVar }) - ) { - return Deno.env.get(clientScopeVar); - } -} diff --git a/lib/oauth_providers.ts b/lib/oauth_providers.ts deleted file mode 100644 index 5f4d1b5..0000000 --- a/lib/oauth_providers.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "$deno_kv_oauth/create_github_oauth_config.ts"; -export * from "$deno_kv_oauth/create_google_oauth_config.ts"; -export * from "$deno_kv_oauth/create_okta_oauth_config.ts"; diff --git a/lib/render_html.tsx b/lib/render_html.tsx index fd4df29..e82e9a1 100644 --- a/lib/render_html.tsx +++ b/lib/render_html.tsx @@ -1,6 +1,10 @@ import { html } from "@http/fns/response/html"; import { prependDocType } from "@http/fns/response/prepend_doctype"; -import { type ComponentType, renderBody, type RenderOptions } from "$jsx"; +import { + type ComponentType, + renderBody, + type RenderOptions, +} from "@http/jsx-stream"; // deno-lint-ignore ban-types export function renderHTML

    ( diff --git a/lib/tag_hooks/github_elements.ts b/lib/tag_hooks/github_elements.ts index 715bf54..8cebadc 100644 --- a/lib/tag_hooks/github_elements.ts +++ b/lib/tag_hooks/github_elements.ts @@ -1,4 +1,4 @@ -import type { TagHandlers } from "$jsx/types"; +import type { TagHandlers } from "@http/jsx-stream/types"; import { inject, recordScript } from "./inject.tsx"; const injectGH = inject((tag) => ({ diff --git a/lib/tag_hooks/inject.tsx b/lib/tag_hooks/inject.tsx index 8d9cc7f..2cef2af 100644 --- a/lib/tag_hooks/inject.tsx +++ b/lib/tag_hooks/inject.tsx @@ -4,7 +4,7 @@ import type { Tag, TagHandlers, TagHooks, -} from "$jsx/types"; +} from "@http/jsx-stream/types"; export interface Injections { module?: string | string[]; diff --git a/lib/tag_hooks/material_design.ts b/lib/tag_hooks/material_design.ts index de75a4b..060466b 100644 --- a/lib/tag_hooks/material_design.ts +++ b/lib/tag_hooks/material_design.ts @@ -1,4 +1,4 @@ -import type { TagHandlers } from "$jsx/types"; +import type { TagHandlers } from "@http/jsx-stream/types"; import { inject, recordScript } from "./inject.tsx"; const mdComponents: Record = { diff --git a/lib/tag_hooks/patternfly_elements.ts b/lib/tag_hooks/patternfly_elements.ts index dacef33..1590252 100644 --- a/lib/tag_hooks/patternfly_elements.ts +++ b/lib/tag_hooks/patternfly_elements.ts @@ -1,4 +1,4 @@ -import type { TagHandlers } from "$jsx/types"; +import type { TagHandlers } from "@http/jsx-stream/types"; import { inject, recordScript } from "./inject.tsx"; export function patternFlyElements(): TagHandlers { diff --git a/lib/tag_hooks/shoelace.ts b/lib/tag_hooks/shoelace.ts index 5b87ec4..19f0c1b 100644 --- a/lib/tag_hooks/shoelace.ts +++ b/lib/tag_hooks/shoelace.ts @@ -1,4 +1,4 @@ -import type { TagHandlers } from "$jsx/types"; +import type { TagHandlers } from "@http/jsx-stream/types"; import { inject, recordScript, recordStylesheet } from "./inject.tsx"; export function shoelaceElements(): TagHandlers { diff --git a/lib/tag_hooks/vaadin.ts b/lib/tag_hooks/vaadin.ts index bf8eb40..ceb6481 100644 --- a/lib/tag_hooks/vaadin.ts +++ b/lib/tag_hooks/vaadin.ts @@ -1,4 +1,4 @@ -import type { TagHandlers } from "$jsx/types"; +import type { TagHandlers } from "@http/jsx-stream/types"; import { inject, recordScript } from "./inject.tsx"; const ignored = ["vaadin-tab"]; diff --git a/lib/tag_hooks/wired_elements.ts b/lib/tag_hooks/wired_elements.ts index aa2c9da..be26206 100644 --- a/lib/tag_hooks/wired_elements.ts +++ b/lib/tag_hooks/wired_elements.ts @@ -1,4 +1,4 @@ -import type { TagHandlers } from "$jsx/types"; +import type { TagHandlers } from "@http/jsx-stream/types"; import { inject, recordScript } from "./inject.tsx"; export function wiredElements(): TagHandlers { diff --git a/routes.ts b/routes.ts index 64f88ff..32d1a17 100644 --- a/routes.ts +++ b/routes.ts @@ -1,8 +1,8 @@ // IMPORTANT: This file has been automatically generated, DO NOT edit by hand. +import { lazy } from "@http/fns/lazy"; import { byPattern } from "@http/fns/by_pattern"; import { cascade } from "@http/fns/cascade"; -import { lazy } from "@http/fns/lazy"; export default cascade( byPattern("/todo/:listId/:itemId", lazy(() => import("./routes/todo/:listId/:itemId.tsx"))), @@ -26,10 +26,6 @@ export default cascade( byPattern(["/blog/md{.:ext}?","/blog/links{.:ext}?","/blog/jsx_streaming{.:ext}?","/blog/index{.:ext}","/blog/http_fns{.:ext}?","/blog/dependency_hell{.:ext}?"], lazy(() => import("./lib/handle_route_md.tsx"))), byPattern("/blog/:path+", lazy(() => import("./lib/handle_route_static_dir.ts"))), byPattern("/blog", lazy(() => import("./lib/handle_route_md.tsx"))), - byPattern("/auth/widget", lazy(() => import("./routes/auth/widget.tsx"))), - byPattern("/auth/signout", lazy(() => import("./routes/auth/signout.ts"))), - byPattern("/auth/:provider/signin", lazy(() => import("./routes/auth/:provider/signin.ts"))), - byPattern("/auth/:provider/callback", lazy(() => import("./routes/auth/:provider/callback.ts"))), byPattern("/async", lazy(() => import("./routes/async.tsx"))), byPattern("/:path+", lazy(() => import("./lib/handle_route_static_dir.ts"))), byPattern("/", lazy(() => import("./routes/index.tsx"))), diff --git a/routes/_static/sw.js b/routes/_static/sw.js index 04573c3..075eda5 100644 --- a/routes/_static/sw.js +++ b/routes/_static/sw.js @@ -1,5 +1,5 @@ (() => { - // https://jsr.io/@http/fns/0.6.4/lib/as_url_pattern.ts + // https://jsr.io/@http/fns/0.7.0/lib/as_url_pattern.ts function asURLPattern(pattern) { return typeof pattern === "string" ? new URLPattern({ pathname: pattern }) : pattern instanceof URLPattern ? pattern : new URLPattern(pattern); } @@ -7,7 +7,7 @@ return Array.isArray(pattern) ? pattern.map(asURLPattern) : [asURLPattern(pattern)]; } - // https://jsr.io/@http/fns/0.6.4/lib/by_pattern.ts + // https://jsr.io/@http/fns/0.7.0/lib/by_pattern.ts function byPattern(pattern, handler) { const patterns = asURLPatterns(pattern); return async (req, ...args) => { @@ -24,7 +24,7 @@ }; } - // https://jsr.io/@http/fns/0.6.4/lib/cascade.ts + // https://jsr.io/@http/fns/0.7.0/lib/cascade.ts function cascade(...handlers) { return async (req, ...args) => { for (const handler of handlers) { @@ -37,7 +37,7 @@ }; } - // https://jsr.io/@http/fns/0.6.4/lib/response/plain_error.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/plain_error.ts function plainError(status, statusText, message) { return new Response(message ?? statusText, { status, @@ -48,12 +48,12 @@ }); } - // https://jsr.io/@http/fns/0.6.4/lib/response/method_not_allowed.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/method_not_allowed.ts function methodNotAllowed(message) { return plainError(405, "Method Not Allowed", message); } - // https://jsr.io/@http/fns/0.6.4/lib/response/no_content.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/no_content.ts function noContent(headers) { return new Response(null, { status: 204, @@ -62,7 +62,7 @@ }); } - // https://jsr.io/@http/fns/0.6.4/lib/response/replace_body.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/replace_body.ts function replaceBody(res, body) { return res.body === body ? res : new Response(body, { status: res.status, @@ -71,7 +71,7 @@ }); } - // https://jsr.io/@http/fns/0.6.4/lib/by_method.ts + // https://jsr.io/@http/fns/0.7.0/lib/by_method.ts function byMethod(handlers, fallback = () => methodNotAllowed()) { const defaultHandlers = { OPTIONS: optionsHandler(handlers) @@ -109,7 +109,7 @@ deferredTimeout: false }; - // https://jsr.io/@http/fns/0.6.4/lib/response/html.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/html.ts function html(body, headersInit) { const headers = new Headers(headersInit); headers.set("Content-Type", "text/html"); @@ -120,7 +120,7 @@ }); } - // https://jsr.io/@http/fns/0.6.4/lib/response/prepend_doctype.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/prepend_doctype.ts var DOCTYPE = "\n"; var ENCODED_DOCTYPE = new TextEncoder().encode(DOCTYPE); function prependDocType(bodyInit) { @@ -594,7 +594,7 @@ return evalRPN(toRPN(tokenize(input))); } - // https://jsr.io/@http/fns/0.6.4/lib/request/search_values.ts + // https://jsr.io/@http/fns/0.7.0/lib/request/search_values.ts function getSearchValues(input) { const searchParams = input instanceof Request ? new URL(input.url).searchParams : input instanceof URL ? input.searchParams : input instanceof URLSearchParams ? input : input && "search" in input && "input" in input.search ? new URLSearchParams(input.search.input) : void 0; return (param, separator) => searchParams ? separator ? searchParams.getAll(param).join(separator).split(separator).filter( diff --git a/routes/_static/sw_compat.js b/routes/_static/sw_compat.js index 577449d..854413e 100644 --- a/routes/_static/sw_compat.js +++ b/routes/_static/sw_compat.js @@ -788,7 +788,7 @@ globalThis.URLPattern = me; } - // https://jsr.io/@http/fns/0.6.4/lib/as_url_pattern.ts + // https://jsr.io/@http/fns/0.7.0/lib/as_url_pattern.ts function asURLPattern(pattern) { return typeof pattern === "string" ? new URLPattern({ pathname: pattern }) : pattern instanceof URLPattern ? pattern : new URLPattern(pattern); } @@ -796,7 +796,7 @@ return Array.isArray(pattern) ? pattern.map(asURLPattern) : [asURLPattern(pattern)]; } - // https://jsr.io/@http/fns/0.6.4/lib/by_pattern.ts + // https://jsr.io/@http/fns/0.7.0/lib/by_pattern.ts function byPattern(pattern, handler) { const patterns = asURLPatterns(pattern); return async (req, ...args) => { @@ -813,7 +813,7 @@ }; } - // https://jsr.io/@http/fns/0.6.4/lib/cascade.ts + // https://jsr.io/@http/fns/0.7.0/lib/cascade.ts function cascade(...handlers) { return async (req, ...args) => { for (const handler of handlers) { @@ -826,7 +826,7 @@ }; } - // https://jsr.io/@http/fns/0.6.4/lib/response/plain_error.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/plain_error.ts function plainError(status, statusText, message) { return new Response(message ?? statusText, { status, @@ -837,12 +837,12 @@ }); } - // https://jsr.io/@http/fns/0.6.4/lib/response/method_not_allowed.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/method_not_allowed.ts function methodNotAllowed(message) { return plainError(405, "Method Not Allowed", message); } - // https://jsr.io/@http/fns/0.6.4/lib/response/no_content.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/no_content.ts function noContent(headers) { return new Response(null, { status: 204, @@ -851,7 +851,7 @@ }); } - // https://jsr.io/@http/fns/0.6.4/lib/response/replace_body.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/replace_body.ts function replaceBody(res, body) { return res.body === body ? res : new Response(body, { status: res.status, @@ -860,7 +860,7 @@ }); } - // https://jsr.io/@http/fns/0.6.4/lib/by_method.ts + // https://jsr.io/@http/fns/0.7.0/lib/by_method.ts function byMethod(handlers, fallback = () => methodNotAllowed()) { const defaultHandlers = { OPTIONS: optionsHandler(handlers) @@ -898,7 +898,7 @@ deferredTimeout: false }; - // https://jsr.io/@http/fns/0.6.4/lib/response/html.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/html.ts function html(body, headersInit) { const headers = new Headers(headersInit); headers.set("Content-Type", "text/html"); @@ -909,7 +909,7 @@ }); } - // https://jsr.io/@http/fns/0.6.4/lib/response/prepend_doctype.ts + // https://jsr.io/@http/fns/0.7.0/lib/response/prepend_doctype.ts var DOCTYPE = "\n"; var ENCODED_DOCTYPE = new TextEncoder().encode(DOCTYPE); function prependDocType(bodyInit) { @@ -1383,7 +1383,7 @@ return evalRPN(toRPN(tokenize(input))); } - // https://jsr.io/@http/fns/0.6.4/lib/request/search_values.ts + // https://jsr.io/@http/fns/0.7.0/lib/request/search_values.ts function getSearchValues(input) { const searchParams = input instanceof Request ? new URL(input.url).searchParams : input instanceof URL ? input.searchParams : input instanceof URLSearchParams ? input : input && "search" in input && "input" in input.search ? new URLSearchParams(input.search.input) : void 0; return (param, separator) => searchParams ? separator ? searchParams.getAll(param).join(separator).split(separator).filter( diff --git a/routes/auth/:provider/callback.ts b/routes/auth/:provider/callback.ts deleted file mode 100644 index a35d645..0000000 --- a/routes/auth/:provider/callback.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { byMethod } from "@http/fns/by_method"; -import { mapData } from "@http/fns/map_data"; -import { handleCallback } from "$deno_kv_oauth/handle_callback.ts"; -import { asOAuth2ClientConfig } from "../_lib/oauth_config.ts"; - -export default byMethod({ - GET: mapData(asOAuth2ClientConfig, async (req, oauth2Client) => { - const { response } = await handleCallback( - req, - oauth2Client, - ); - return response; - }), -}); diff --git a/routes/auth/:provider/signin.ts b/routes/auth/:provider/signin.ts deleted file mode 100644 index c24a7b0..0000000 --- a/routes/auth/:provider/signin.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { byMethod } from "@http/fns/by_method"; -import { mapData } from "@http/fns/map_data"; -import { signIn } from "$deno_kv_oauth/sign_in.ts"; -import { asOAuth2ClientConfig } from "../_lib/oauth_config.ts"; - -export default byMethod({ - GET: mapData(asOAuth2ClientConfig, signIn), -}); diff --git a/routes/auth/_lib/oauth_config.ts b/routes/auth/_lib/oauth_config.ts deleted file mode 100644 index 6b14ef2..0000000 --- a/routes/auth/_lib/oauth_config.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { badRequest } from "@http/fns/response/bad_request"; -import { notFound } from "@http/fns/response/not_found"; -import { - getOAuthClientScope, - getOAuthConfigFn, - type OAuth2ClientConfig, -} from "../../../lib/oauth_config.ts"; - -export async function asOAuth2ClientConfig( - req: Request, - match: URLPatternResult, -): Promise { - const provider = match.pathname.groups.provider; - - if (!provider) { - throw badRequest(); - } - - const createOAuthConfig = getOAuthConfigFn(provider); - - if (!createOAuthConfig) { - throw notFound(); - } - - const redirectUri = new URL("callback", req.url).href; - const scope = await getOAuthClientScope(provider); - - return createOAuthConfig({ - redirectUri, - scope, - }); -} diff --git a/routes/auth/signout.ts b/routes/auth/signout.ts deleted file mode 100644 index be45361..0000000 --- a/routes/auth/signout.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { byMethod } from "@http/fns/by_method"; -import { signOut } from "$deno_kv_oauth/sign_out.ts"; - -export default byMethod({ - GET: signOut, -}); diff --git a/routes/auth/widget.tsx b/routes/auth/widget.tsx deleted file mode 100644 index 9ed8d12..0000000 --- a/routes/auth/widget.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { handleFragment } from "../../lib/handle_fragment.ts"; -import { UserWidget } from "../../components/UserWidget.tsx"; - -export default handleFragment(({ req }) => { - return ; -}); diff --git a/routes/quote/_lib/quote_config.ts b/routes/quote/_lib/quote_config.ts index 0b767b1..cc16c88 100644 --- a/routes/quote/_lib/quote_config.ts +++ b/routes/quote/_lib/quote_config.ts @@ -1,3 +1,5 @@ +import { getEnv } from "@cross/env"; + export interface QuoteConfig { /** * Cron schedule for generating a new quote @@ -30,12 +32,12 @@ let _config: QuoteConfig | undefined; export function getQuoteConfig(): QuoteConfig { if (!_config) { _config = { - schedule: Deno.env.get("QUOTE_SCHEDULE") ?? "*/5 * * * *", - refresh: parseInt(Deno.env.get("QUOTE_TV_REFRESH") ?? "") || (6 * 60), - model: Deno.env.get("QUOTE_AI_MODEL") ?? "gpt-3.5-turbo", - temperature: parseFloat(Deno.env.get("QUOTE_AI_TEMPERATURE") ?? "") || + schedule: getEnv("QUOTE_SCHEDULE") ?? "*/5 * * * *", + refresh: parseInt(getEnv("QUOTE_TV_REFRESH") ?? "") || (6 * 60), + model: getEnv("QUOTE_AI_MODEL") ?? "gpt-3.5-turbo", + temperature: parseFloat(getEnv("QUOTE_AI_TEMPERATURE") ?? "") || 1.5, - prompt: Deno.env.get("QUOTE_AI_PROMPT") ?? + prompt: getEnv("QUOTE_AI_PROMPT") ?? "Generate a new obscure inspirational quote of the day. Do not attribute it to anyone.", }; } diff --git a/routes/quote/tv.ts b/routes/quote/tv.ts index f3edc25..27b2de6 100644 --- a/routes/quote/tv.ts +++ b/routes/quote/tv.ts @@ -4,7 +4,7 @@ import { QuoteTvPage } from "./_components/QuoteTvPage.tsx"; import { getQuoteConfig } from "./_lib/quote_config.ts"; export default byMethod({ - GET: (req) => { + GET: (req, _match) => { return renderHTML(QuoteTvPage, { refresh: getRefresh(req) }); }, }); diff --git a/routes/sse/feed.tsx b/routes/sse/feed.tsx index 5949fc5..29085d0 100644 --- a/routes/sse/feed.tsx +++ b/routes/sse/feed.tsx @@ -1,7 +1,7 @@ import { delay } from "@std/async/delay"; import { ok } from "@http/fns/response/ok"; -import { renderString } from "$jsx"; -import type { JSX } from "$jsx/jsx-runtime"; +import { renderString } from "@http/jsx-stream"; +import type { JSX } from "@http/jsx-stream/jsx-runtime"; export default function (_req: Request) { const body = ReadableStream.from(streamEvents()) diff --git a/scripts/build.ts b/scripts/build.ts index a65c8a9..643af58 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -26,7 +26,7 @@ export async function buildServiceWorker() { format: "iife", treeShaking: true, jsx: "automatic", - jsxImportSource: "$jsx", + jsxImportSource: "@http/jsx-stream", // minify: true });