From 6a51f6279c16f71fed340ee1cd2440431a3cd179 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Sat, 23 Mar 2024 14:47:41 -0500 Subject: [PATCH 01/19] chore: bump fresh --- deno.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deno.json b/deno.json index 83863af6..d5ae0ded 100644 --- a/deno.json +++ b/deno.json @@ -24,14 +24,14 @@ }, "imports": { "$std/": "https://deno.land/std@0.216.0/", - "$fresh/": "https://deno.land/x/fresh@1.6.5/", + "$fresh/": "https://deno.land/x/fresh@1.6.8/", "$gfm": "https://deno.land/x/gfm@0.6.0/mod.ts", "openai": "https://deno.land/x/openai@v4.29.2/mod.ts", "openai/": "https://deno.land/x/openai@v4.29.2/", "$tabler_icons/": "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/", "zod": "https://deno.land/x/zod@v3.22.4/mod.ts", "@headlessui/react": "https://esm.sh/v135/*@headlessui/react@1.7.17", - "@preact/signals-core": "https://esm.sh/v135/@preact/signals-core@1.5.1", + "@preact/signals-core": "https://esm.sh/v135/*@preact/signals-core@1.5.1", "@preact/signals": "https://esm.sh/v135/*@preact/signals@1.2.2", "preact": "https://esm.sh/v135/preact@10.19.6", "preact/": "https://esm.sh/v135/preact@10.19.6/", From a5d17b6c4a94243d915605244018bf74892ec5e4 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Sat, 23 Mar 2024 14:47:56 -0500 Subject: [PATCH 02/19] chore: migrate to jsr --- deno.json | 27 ++++++++++---------- src/dev.ts | 2 -- src/islands/Chatbot.tsx | 2 +- src/main.ts | 2 -- src/routes/about.test.ts | 2 +- src/routes/solutions/[category]/[[slug]].tsx | 2 +- src/utils/solutions.test.ts | 2 +- src/utils/tailwind.test.ts | 2 +- tool/compile-mdx.ts | 8 +----- 9 files changed, 20 insertions(+), 29 deletions(-) diff --git a/deno.json b/deno.json index d5ae0ded..4a1f5365 100644 --- a/deno.json +++ b/deno.json @@ -10,7 +10,7 @@ "test:coverage:genhtml": "genhtml -o cov/html cov/cov.lcov", "manifest": "deno task cli manifest $(pwd)", "start": "deno run --env -A --watch src/dev.ts", - "build": "deno task compile:mdx && deno run -A src/dev.ts build", + "build": "deno task compile:mdx && deno run --env -A src/dev.ts build", "preview": "deno run --env -A src/main.ts", "update": "deno run -A -r https://fresh.deno.dev/update .", "esm": "deno run -A https://esm.sh/v135", @@ -23,32 +23,32 @@ "compile:mdx": "deno run -A tool/compile-mdx.ts" }, "imports": { - "$std/": "https://deno.land/std@0.216.0/", "$fresh/": "https://deno.land/x/fresh@1.6.8/", - "$gfm": "https://deno.land/x/gfm@0.6.0/mod.ts", - "openai": "https://deno.land/x/openai@v4.29.2/mod.ts", - "openai/": "https://deno.land/x/openai@v4.29.2/", "$tabler_icons/": "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/", - "zod": "https://deno.land/x/zod@v3.22.4/mod.ts", + "@deno/gfm": "jsr:@deno/gfm@^0.8.0", "@headlessui/react": "https://esm.sh/v135/*@headlessui/react@1.7.17", - "@preact/signals-core": "https://esm.sh/v135/*@preact/signals-core@1.5.1", - "@preact/signals": "https://esm.sh/v135/*@preact/signals@1.2.2", - "preact": "https://esm.sh/v135/preact@10.19.6", - "preact/": "https://esm.sh/v135/preact@10.19.6/", "@headlessui/tailwindcss": "npm:@headlessui/tailwindcss@0.2.0", "@mdx-js/mdx": "npm:@mdx-js/mdx@3.0.1", + "@preact/signals": "https://esm.sh/v135/*@preact/signals@1.2.2", + "@preact/signals-core": "https://esm.sh/v135/*@preact/signals-core@1.5.1", + "@std/assert": "jsr:@std/assert@^0.220.1", + "@std/path": "jsr:@std/path@^0.220.1", "@tailwindcss/forms": "npm:@tailwindcss/forms@0.5.7", "@tailwindcss/typography": "npm:@tailwindcss/typography@0.5.10", "idb-keyval": "npm:idb-keyval@6.2.1", + "openai": "https://deno.land/x/openai@v4.29.2/mod.ts", + "openai/": "https://deno.land/x/openai@v4.29.2/", + "preact": "https://esm.sh/v135/preact@10.19.6", + "preact/": "https://esm.sh/v135/preact@10.19.6/", "rehype-mathjax": "npm:rehype-mathjax@6.0.0", "remark-frontmatter": "npm:remark-frontmatter@5.0.0", "remark-lint-checkbox-content-indent": "npm:remark-lint-checkbox-content-indent@4.1.1", - "remark-lint-no-tabs": "npm:remark-lint-no-tabs@3.1.1", "remark-lint-definition-spacing": "npm:remark-lint-definition-spacing@3.1.1", "remark-lint-heading-increment": "npm:remark-lint-heading-increment@3.1.1", "remark-lint-linebreak-style": "npm:remark-lint-linebreak-style@3.1.1", - "remark-lint-no-missing-blank-lines": "npm:remark-lint-no-missing-blank-lines@3.1.1", "remark-lint-no-consecutive-blank-lines": "npm:remark-lint-no-consecutive-blank-lines@4.1.2", + "remark-lint-no-missing-blank-lines": "npm:remark-lint-no-missing-blank-lines@3.1.1", + "remark-lint-no-tabs": "npm:remark-lint-no-tabs@3.1.1", "remark-math": "npm:remark-math@6.0.0", "remark-mdx-frontmatter": "npm:remark-mdx-frontmatter@4.0.0", "remark-preset-lint-consistent": "npm:remark-preset-lint-consistent@5.1.2", @@ -56,9 +56,10 @@ "tailwindcss": "npm:tailwindcss@3.4.1", "tailwindcss/plugin": "npm:tailwindcss@3.4.1/plugin.js", "unified": "npm:unified@11.0.4", + "vfile": "npm:vfile@6.0.1", "vfile-matter": "npm:vfile-matter@5.0.0", "vfile-reporter": "npm:vfile-reporter@8.1.0", - "vfile": "npm:vfile@6.0.1" + "zod": "https://deno.land/x/zod@v3.22.4/mod.ts" }, "scopes": { "https://esm.sh/v135/": { diff --git a/src/dev.ts b/src/dev.ts index ae73946d..1fe3e340 100755 --- a/src/dev.ts +++ b/src/dev.ts @@ -3,6 +3,4 @@ import dev from "$fresh/dev.ts"; import config from "./fresh.config.ts"; -import "$std/dotenv/load.ts"; - await dev(import.meta.url, "./main.ts", config); diff --git a/src/islands/Chatbot.tsx b/src/islands/Chatbot.tsx index 54e2f464..ce9fec68 100644 --- a/src/islands/Chatbot.tsx +++ b/src/islands/Chatbot.tsx @@ -1,4 +1,4 @@ -import { render } from "$gfm"; +import { render } from "@deno/gfm"; import { Transition } from "@headlessui/react"; import { useSignal, useSignalEffect } from "@preact/signals"; import { set } from "idb-keyval"; diff --git a/src/main.ts b/src/main.ts index 38dcdc24..c1e3c4db 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,8 +4,6 @@ /// /// -import "$std/dotenv/load.ts"; - import { start } from "$fresh/server.ts"; import config from "./fresh.config.ts"; import manifest from "./fresh.gen.ts"; diff --git a/src/routes/about.test.ts b/src/routes/about.test.ts index 2e650e4e..c53fe684 100644 --- a/src/routes/about.test.ts +++ b/src/routes/about.test.ts @@ -1,5 +1,5 @@ import { type ServeHandlerInfo, createHandler } from "$fresh/server.ts"; -import { assertStringIncludes } from "$std/assert/mod.ts"; +import { assertStringIncludes } from "@std/assert"; import config from "../fresh.config.ts"; import manifest from "../fresh.gen.ts"; diff --git a/src/routes/solutions/[category]/[[slug]].tsx b/src/routes/solutions/[category]/[[slug]].tsx index 1809fa0e..b3cb7b61 100644 --- a/src/routes/solutions/[category]/[[slug]].tsx +++ b/src/routes/solutions/[category]/[[slug]].tsx @@ -1,6 +1,6 @@ import { Head } from "$fresh/runtime.ts"; import type { Handlers, PageProps, RouteConfig } from "$fresh/server.ts"; -import { join } from "$std/path/mod.ts"; +import { join } from "@std/path"; import type { JSX } from "preact"; import { Content } from "../../../components/Content.tsx"; import { Cover } from "../../../components/Cover.tsx"; diff --git a/src/utils/solutions.test.ts b/src/utils/solutions.test.ts index 357e688e..451840cb 100644 --- a/src/utils/solutions.test.ts +++ b/src/utils/solutions.test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "$std/assert/mod.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { ZodError } from "zod"; import { solutionPagesSchema } from "./solutions.ts"; diff --git a/src/utils/tailwind.test.ts b/src/utils/tailwind.test.ts index fb05702c..ab9e20ae 100644 --- a/src/utils/tailwind.test.ts +++ b/src/utils/tailwind.test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "$std/assert/mod.ts"; +import { assertEquals } from "@std/assert"; import { tw } from "./tailwind.ts"; /** diff --git a/tool/compile-mdx.ts b/tool/compile-mdx.ts index a0bf769c..a7d04e0f 100644 --- a/tool/compile-mdx.ts +++ b/tool/compile-mdx.ts @@ -1,11 +1,5 @@ -import { - dirname, - fromFileUrl, - join, - relative, - resolve, -} from "$std/path/mod.ts"; import { type CompileOptions, compile } from "@mdx-js/mdx"; +import { dirname, fromFileUrl, join, relative, resolve } from "@std/path"; import rehypeMathjax from "rehype-mathjax"; import remarkFrontmatter from "remark-frontmatter"; import remarkLintCheckboxContentIndent from "remark-lint-checkbox-content-indent"; From 7f19659c6bd67193b4e9448637c72c3b8399350a Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Sun, 24 Mar 2024 19:00:15 -0500 Subject: [PATCH 03/19] fix: homepage dark mode Fixes: #38. --- src/routes/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 2f66210c..478aa872 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -31,7 +31,7 @@ function Card({ }: RenderableProps): JSX.Element { return (

Date: Mon, 8 Apr 2024 16:36:42 -0500 Subject: [PATCH 04/19] fix: checkboxes Without this, the checkboxes would not be rendered correctly. They weren't checked when the user clicked on them. This was due to another annoying csp violation. Oversight on my part. I apologize, I hope this is the last time I have to fix this. --- src/utils/csp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/csp.ts b/src/utils/csp.ts index 2caa8226..28f43243 100644 --- a/src/utils/csp.ts +++ b/src/utils/csp.ts @@ -12,7 +12,7 @@ export function useCsp(): void { csp.directives.scriptSrcElem.push(SELF, UNSAFE_INLINE); csp.directives.styleSrc.push(SELF); csp.directives.styleSrcElem.push(SELF, UNSAFE_INLINE); - csp.directives.imgSrc.push(SELF); + csp.directives.imgSrc.push(SELF, "data:"); csp.directives.connectSrc.push(SELF); csp.directives.manifestSrc.push(SELF); }); From 4eae25622aaa06b1ada948abde1c130b6f7c645a Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:41:37 -0500 Subject: [PATCH 05/19] chore: less code 54 characters removed, for a total of a 50 line reduction of code! --- src/islands/Chatbot.tsx | 2 +- src/utils/calc/solar.ts | 50 ----------------------------------------- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/src/islands/Chatbot.tsx b/src/islands/Chatbot.tsx index ce9fec68..7c929075 100644 --- a/src/islands/Chatbot.tsx +++ b/src/islands/Chatbot.tsx @@ -108,7 +108,7 @@ function ChatbotBox(props: JSX.HTMLAttributes): JSX.Element { key={msg.message} class={`${getReplySide(msg.role)} ${replyStyles}`} // biome-ignore lint/security/noDangerouslySetInnerHtml: It's back! - dangerouslySetInnerHTML={{ __html: render(msg.message, {}) }} + dangerouslySetInnerHTML={{ __html: render(msg.message) }} /> ))}

diff --git a/src/utils/calc/solar.ts b/src/utils/calc/solar.ts index ee0844de..eda03223 100644 --- a/src/utils/calc/solar.ts +++ b/src/utils/calc/solar.ts @@ -22,7 +22,6 @@ export const stateData = { rebate: (10542 / 70) * 100 * 0.3, emissions: 1178 * 0.86, }, - Alaska: { payoff: 6.56, savings: 1669 / 12, @@ -30,7 +29,6 @@ export const stateData = { rebate: (10941 / 70) * 100 * 0.3, emissions: 6.56 * 0.86, }, - Arizona: { payoff: 5.76, savings: 1849 / 12, @@ -38,7 +36,6 @@ export const stateData = { rebate: (10654 / 70) * 100 * 0.3, emissions: 5.76 * 0.86, }, - Arkansas: { payoff: 6.95, savings: 1693 / 12, @@ -46,7 +43,6 @@ export const stateData = { rebate: (11771 / 70) * 100 * 0.3, emissions: 6.95 * 0.86, }, - California: { payoff: 6.8, savings: 1715 / 12, @@ -54,7 +50,6 @@ export const stateData = { rebate: (11666 / 70) * 100 * 0.3, emissions: 6.8 * 0.86, }, - Colorado: { payoff: 10.17, savings: 1207 / 12, @@ -62,7 +57,6 @@ export const stateData = { rebate: (12278 / 70) * 100 * 0.3, emissions: 10.17 * 0.86, }, - Connecticut: { payoff: 5.05, savings: 2487 / 12, @@ -70,7 +64,6 @@ export const stateData = { rebate: (12558 / 70) * 100 * 0.3, emissions: 5.05 * 0.86, }, - Delaware: { payoff: 5.79, savings: 1972 / 12, @@ -78,7 +71,6 @@ export const stateData = { rebate: (11414 / 70) * 100 * 0.3, emissions: 5.79 * 0.86, }, - "District of Columbia": { payoff: 8.17, savings: 1481 / 12, @@ -86,7 +78,6 @@ export const stateData = { rebate: (12100 / 70) * 100 * 0.3, emissions: 8.17 * 0.86, }, - Florida: { payoff: 5.71, savings: 2064 / 12, @@ -94,7 +85,6 @@ export const stateData = { rebate: (11788 / 70) * 100 * 0.3, emissions: 5.71 * 0.86, }, - Georgia: { payoff: 6.43, savings: 1808 / 12, @@ -102,7 +92,6 @@ export const stateData = { rebate: (11634 / 70) * 100 * 0.3, emissions: 6.43 * 0.86, }, - Hawaii: { payoff: 4.35, savings: 2638 / 12, @@ -110,7 +99,6 @@ export const stateData = { rebate: (11466 / 70) * 100 * 0.3, emissions: 4.35 * 0.86, }, - Idaho: { payoff: 8.26, savings: 1465 / 12, @@ -118,7 +106,6 @@ export const stateData = { rebate: (12107 / 70) * 100 * 0.3, emissions: 8.26 * 0.86, }, - Illinois: { payoff: 9.61, savings: 1368 / 12, @@ -126,7 +113,6 @@ export const stateData = { rebate: (13146 / 70) * 100 * 0.3, emissions: 9.61 * 0.86, }, - Indiana: { payoff: 7.65, savings: 1729 / 12, @@ -134,7 +120,6 @@ export const stateData = { rebate: (13230 / 70) * 100 * 0.3, emissions: 7.65 * 0.86, }, - Iowa: { payoff: 8.67, savings: 1425 / 12, @@ -142,7 +127,6 @@ export const stateData = { rebate: (12348 / 70) * 100 * 0.3, emissions: 8.67 * 0.86, }, - Kansas: { payoff: 7.31, savings: 1528 / 12, @@ -150,7 +134,6 @@ export const stateData = { rebate: (11172 / 70) * 100 * 0.3, emissions: 7.31 * 0.86, }, - Kentucky: { payoff: 6.55, savings: 1705 / 12, @@ -158,7 +141,6 @@ export const stateData = { rebate: (11172 / 70) * 100 * 0.3, emissions: 6.55 * 0.86, }, - Louisiana: { payoff: 6.76, savings: 1761 / 12, @@ -166,7 +148,6 @@ export const stateData = { rebate: (11907 / 70) * 100 * 0.3, emissions: 6.76 * 0.86, }, - Maine: { payoff: 6.61, savings: 2038 / 12, @@ -174,7 +155,6 @@ export const stateData = { rebate: (13461 / 70) * 100 * 0.3, emissions: 6.61 * 0.86, }, - Maryland: { payoff: 5.8, savings: 2137 / 12, @@ -182,7 +162,6 @@ export const stateData = { rebate: (12401 / 70) * 100 * 0.3, emissions: 5.8 * 0.86, }, - Massachusetts: { payoff: 7.82, savings: 2137 / 12, @@ -190,7 +169,6 @@ export const stateData = { rebate: (15162 / 70) * 100 * 0.3, emissions: 7.82 * 0.86, }, - Michigan: { payoff: 8.97, savings: 1491 / 12, @@ -198,7 +176,6 @@ export const stateData = { rebate: (13377 / 70) * 100 * 0.3, emissions: 8.97 * 0.86, }, - Minnesota: { payoff: 9.23, savings: 1418 / 12, @@ -206,7 +183,6 @@ export const stateData = { rebate: (13083 / 70) * 100 * 0.3, emissions: 9.23 * 0.86, }, - Mississippi: { payoff: 5.84, savings: 1946 / 12, @@ -214,7 +190,6 @@ export const stateData = { rebate: (11361 / 70) * 100 * 0.3, emissions: 5.84 * 0.86, }, - Missouri: { payoff: 7.35, savings: 1605 / 12, @@ -222,7 +197,6 @@ export const stateData = { rebate: (11792 / 70) * 100 * 0.3, emissions: 7.35 * 0.86, }, - Montana: { payoff: 7.84, savings: 1412 / 12, @@ -230,7 +204,6 @@ export const stateData = { rebate: (11067 / 70) * 100 * 0.3, emissions: 7.84 * 0.86, }, - Nebraska: { payoff: 8.42, savings: 1472 / 12, @@ -238,7 +211,6 @@ export const stateData = { rebate: (12390 / 70) * 100 * 0.3, emissions: 8.42 * 0.86, }, - Nevada: { payoff: 6.52, savings: 1649 / 12, @@ -246,7 +218,6 @@ export const stateData = { rebate: (10752 / 70) * 100 * 0.3, emissions: 6.52 * 0.86, }, - "New Hampshire": { payoff: 7.17, savings: 1926 / 12, @@ -254,7 +225,6 @@ export const stateData = { rebate: (13818 / 70) * 100 * 0.3, emissions: 7.17 * 0.86, }, - "New Jersey": { payoff: 6.58, savings: 1858 / 12, @@ -262,7 +232,6 @@ export const stateData = { rebate: (12222 / 70) * 100 * 0.3, emissions: 6.58 * 0.86, }, - "New Mexico": { payoff: 10.52, savings: 1147 / 12, @@ -270,7 +239,6 @@ export const stateData = { rebate: (12065 / 70) * 100 * 0.3, emissions: 10.52 * 0.86, }, - "New York": { payoff: 8.11, savings: 1613 / 12, @@ -278,7 +246,6 @@ export const stateData = { rebate: (13083 / 70) * 100 * 0.3, emissions: 8.11 * 0.86, }, - "North Carolina": { payoff: 6.06, savings: 1897 / 12, @@ -286,7 +253,6 @@ export const stateData = { rebate: (11487 / 70) * 100 * 0.3, emissions: 6.06 * 0.86, }, - "North Dakota": { payoff: 6.6, savings: 1566 / 12, @@ -294,7 +260,6 @@ export const stateData = { rebate: (10332 / 70) * 100 * 0.3, emissions: 6.6 * 0.86, }, - Ohio: { payoff: 6.85, savings: 1679 / 12, @@ -302,7 +267,6 @@ export const stateData = { rebate: (11498 / 70) * 100 * 0.3, emissions: 6.85 * 0.86, }, - Oklahoma: { payoff: 6.04, savings: 1839 / 12, @@ -310,7 +274,6 @@ export const stateData = { rebate: (11102 / 70) * 100 * 0.3, emissions: 6.04 * 0.86, }, - Oregon: { payoff: 8.17, savings: 1503 / 12, @@ -318,7 +281,6 @@ export const stateData = { rebate: (12285 / 70) * 100 * 0.3, emissions: 8.17 * 0.86, }, - Pennsylvania: { payoff: 6.48, savings: 1889 / 12, @@ -326,7 +288,6 @@ export const stateData = { rebate: (12233 / 70) * 100 * 0.3, emissions: 6.48 * 0.86, }, - "Rhode Island": { payoff: 5.98, savings: 2246 / 12, @@ -334,7 +295,6 @@ export const stateData = { rebate: (13419 / 70) * 100 * 0.3, emissions: 5.98 * 0.86, }, - "South Carolina": { payoff: 6.1, savings: 1889 / 12, @@ -342,7 +302,6 @@ export const stateData = { rebate: (11519 / 70) * 100 * 0.3, emissions: 6.1 * 0.86, }, - "South Dakota": { payoff: 6.18, savings: 1649 / 12, @@ -350,7 +309,6 @@ export const stateData = { rebate: (10192 / 70) * 100 * 0.3, emissions: 6.18 * 0.86, }, - Tennessee: { payoff: 6.73, savings: 1792 / 12, @@ -358,7 +316,6 @@ export const stateData = { rebate: (12054 / 70) * 100 * 0.3, emissions: 6.73 * 0.86, }, - Texas: { payoff: 5.33, savings: 2079 / 12, @@ -366,7 +323,6 @@ export const stateData = { rebate: (11088 / 70) * 100 * 0.3, emissions: 5.33 * 0.86, }, - Utah: { payoff: 10.71, savings: 1054 / 12, @@ -374,7 +330,6 @@ export const stateData = { rebate: (11288 / 70) * 100 * 0.3, emissions: 10.71 * 0.86, }, - Vermont: { payoff: 8.57, savings: 1507 / 12, @@ -382,7 +337,6 @@ export const stateData = { rebate: (12915 / 70) * 100 * 0.3, emissions: 8.57 * 0.86, }, - Virginia: { payoff: 6.54, savings: 1860 / 12, @@ -390,7 +344,6 @@ export const stateData = { rebate: (12170 / 70) * 100 * 0.3, emissions: 6.54 * 0.86, }, - Washington: { payoff: 9.05, savings: 1379 / 12, @@ -398,7 +351,6 @@ export const stateData = { rebate: (12485 / 70) * 100 * 0.3, emissions: 9.05 * 0.86, }, - "West Virginia": { payoff: 6.08, savings: 1942 / 12, @@ -406,7 +358,6 @@ export const stateData = { rebate: (11813 / 70) * 100 * 0.3, emissions: 6.08 * 0.86, }, - Wisconsin: { payoff: 9.17, savings: 1400 / 12, @@ -414,7 +365,6 @@ export const stateData = { rebate: (12842 / 70) * 100 * 0.3, emissions: 9.17 * 0.86, }, - Wyoming: { payoff: 8.29, savings: 1333 / 12, From 30565cc17e53f7f387250a4d0060e2c91977a510 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Sat, 4 May 2024 13:12:24 -0500 Subject: [PATCH 06/19] chore(deps): bump Bump preact. Downgrade gfm to a csr compatible version. HeadlessUI v2.0 is broken, and HeadlessUI v1.18 added code from v2.0. It's mostly turned off, but it's still in the bundle. It relies on process.env.JEST_WORKER_ID to disable some features. We use combobox, the affected component, so we can't upgrade. --- deno.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/deno.json b/deno.json index 4a1f5365..7c8b6e80 100644 --- a/deno.json +++ b/deno.json @@ -25,7 +25,7 @@ "imports": { "$fresh/": "https://deno.land/x/fresh@1.6.8/", "$tabler_icons/": "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/", - "@deno/gfm": "jsr:@deno/gfm@^0.8.0", + "@deno/gfm": "https://deno.land/x/gfm@0.6.0/mod.ts", "@headlessui/react": "https://esm.sh/v135/*@headlessui/react@1.7.17", "@headlessui/tailwindcss": "npm:@headlessui/tailwindcss@0.2.0", "@mdx-js/mdx": "npm:@mdx-js/mdx@3.0.1", @@ -38,8 +38,8 @@ "idb-keyval": "npm:idb-keyval@6.2.1", "openai": "https://deno.land/x/openai@v4.29.2/mod.ts", "openai/": "https://deno.land/x/openai@v4.29.2/", - "preact": "https://esm.sh/v135/preact@10.19.6", - "preact/": "https://esm.sh/v135/preact@10.19.6/", + "preact": "https://esm.sh/v135/preact@10.21.0", + "preact/": "https://esm.sh/v135/preact@10.21.0/", "rehype-mathjax": "npm:rehype-mathjax@6.0.0", "remark-frontmatter": "npm:remark-frontmatter@5.0.0", "remark-lint-checkbox-content-indent": "npm:remark-lint-checkbox-content-indent@4.1.1", @@ -65,10 +65,10 @@ "https://esm.sh/v135/": { "@preact/signals-react": "https://esm.sh/v135/*@preact/signals@1.2.2", "client-only": "https://esm.sh/v135/client-only@0.0.1", - "react-dom": "https://esm.sh/v135/preact@10.19.6/compat", - "react": "https://esm.sh/v135/preact@10.19.6/compat", - "react/jsx-runtime": "https://esm.sh/v135/preact@10.19.6/jsx-runtime", - "react-dom/test-utils": "https://esm.sh/v135/preact@10.19.6/test-utils" + "react-dom": "https://esm.sh/v135/preact@10.21.0/compat", + "react": "https://esm.sh/v135/preact@10.21.0/compat", + "react/jsx-runtime": "https://esm.sh/v135/preact@10.21.0/jsx-runtime", + "react-dom/test-utils": "https://esm.sh/v135/preact@10.21.0/test-utils" } }, "compilerOptions": { From 76d427289601dcf83923712eb01f7eb7fff7c607 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Sun, 5 May 2024 16:50:22 -0500 Subject: [PATCH 07/19] chore(deps-dev): bump biome I disabled some rules: useDefaultSwitchClause doesn't have type information. --- biome.json | 8 +++++--- deno.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/biome.json b/biome.json index 07cacdae..9e2bdac2 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", + "$schema": "https://biomejs.dev/schemas/1.7.3/schema.json", "organizeImports": { "enabled": true }, @@ -17,11 +17,13 @@ "useImportRestrictions": "off", "useSortedClasses": "off", "noConsole": "off", - "useJsxKeyInIterable": "off" + "useDefaultSwitchClause": "off" }, "style": { "noImplicitBoolean": "off", - "noDefaultExport": "off" + "noDefaultExport": "off", + "useNamingConvention": "off", + "useFilenamingConvention": "off" }, "complexity": { "useLiteralKeys": "off" diff --git a/deno.json b/deno.json index 7c8b6e80..a90c24b5 100644 --- a/deno.json +++ b/deno.json @@ -17,7 +17,7 @@ "esm:add": "deno task esm add", "esm:update": "deno task esm update", "esm:remove": "deno task esm remove", - "biome": "deno run -A npm:@biomejs/biome@1.6.1", + "biome": "deno run -A npm:@biomejs/biome@1.7.3", "biome:ci": "deno task biome ci . --error-on-warnings", "biome:check": "deno task biome check . --error-on-warnings", "compile:mdx": "deno run -A tool/compile-mdx.ts" From cc4dafa08e7fab769fc02e57cc55984e45e7daeb Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Sun, 5 May 2024 16:53:17 -0500 Subject: [PATCH 08/19] fix: new lints It found a real bug in compile-mdx. Luckily, JS was lenient enough it didn't make a big deal. --- src/islands/Chatbot.tsx | 4 +- src/routes/api/chat/index.ts | 7 +++- src/routes/calculator.tsx | 2 +- src/utils/hooks.ts | 2 +- src/utils/indexeddb.ts | 5 +-- src/utils/solutions.test.ts | 73 +++++++++++++++++------------------- tool/compile-mdx.ts | 8 ++-- 7 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/islands/Chatbot.tsx b/src/islands/Chatbot.tsx index ce9fec68..4fa2628e 100644 --- a/src/islands/Chatbot.tsx +++ b/src/islands/Chatbot.tsx @@ -74,13 +74,11 @@ function ChatbotBox(props: JSX.HTMLAttributes): JSX.Element { const isAsking = useSignal(false); const thread = useIndexedDB( "thread", - [], async () => (await getThread())?.id, ); const messages_ = useIndexedDB( "messages", - [], // deno-lint-ignore require-await async () => [], ); @@ -105,7 +103,7 @@ function ChatbotBox(props: JSX.HTMLAttributes): JSX.Element { )} {messages.value.map((msg) => (
= { async GET(req, ctx): Promise { @@ -12,7 +15,7 @@ export const handler: Handlers = { } const response = ask(message, thread_id); - const responses = []; + const responses: Message[] = []; for await (const res of response) { responses.push(res); } diff --git a/src/routes/calculator.tsx b/src/routes/calculator.tsx index bf88efab..1c429207 100644 --- a/src/routes/calculator.tsx +++ b/src/routes/calculator.tsx @@ -73,7 +73,7 @@ export const handler: Handlers = { }); } - if (!geoType.success || !squareFootage) { + if (!(geoType.success && squareFootage)) { return ctx.renderNotFound(); } diff --git a/src/utils/hooks.ts b/src/utils/hooks.ts index 2a10ace6..4d78852f 100644 --- a/src/utils/hooks.ts +++ b/src/utils/hooks.ts @@ -14,7 +14,7 @@ export function usePromise(promise: Promise): T | undefined { error.value = e; status.value = "rejected"; } - }, [promise]); + }, [promise, status, result, error]); // Preact Signals dislike promises. const [dataPromise] = useState(fetchData); diff --git a/src/utils/indexeddb.ts b/src/utils/indexeddb.ts index d32d0c11..e0d00c91 100644 --- a/src/utils/indexeddb.ts +++ b/src/utils/indexeddb.ts @@ -1,6 +1,6 @@ import { IS_BROWSER } from "$fresh/runtime.ts"; import { get, set } from "idb-keyval"; -import { type Inputs, useCallback } from "preact/hooks"; +import { useCallback } from "preact/hooks"; import { usePromise } from "./hooks.ts"; /** @@ -16,7 +16,6 @@ import { usePromise } from "./hooks.ts"; */ export function useIndexedDB( key: string, - inputs: Inputs, def?: () => Promise, ): T | undefined { if (!IS_BROWSER) { @@ -35,7 +34,7 @@ export function useIndexedDB( } return val; - }, [key, def, inputs]); + }, [key, def]); return usePromise(callback()); } diff --git a/src/utils/solutions.test.ts b/src/utils/solutions.test.ts index 451840cb..700738b1 100644 --- a/src/utils/solutions.test.ts +++ b/src/utils/solutions.test.ts @@ -5,46 +5,43 @@ import { solutionPagesSchema } from "./solutions.ts"; /** * Test the solution pages schema. */ -Deno.test( - "Solution pages schema.", - async (t: Deno.TestContext): Promise => { - await t.step("Valid data", (): void => { - const value = [ - { - slug: "slug", - data: { - title: "", - description: "", - category: "", - sectionHeader: "", - }, +Deno.test("Solution pages schema.", async (t: Deno.TestContext): Promise => { + await t.step("Valid data", (): void => { + const value = [ + { + slug: "slug", + data: { + title: "", + description: "", + category: "", + sectionHeader: "", }, - ]; + }, + ]; - const actual = solutionPagesSchema.parse(value); - assertEquals(actual, value); - }); + const actual = solutionPagesSchema.parse(value); + assertEquals(actual, value); + }); - await t.step("Invalid data", async (t): Promise => { - await t.step("Empty", (): void => { - const actual = (): void => { - solutionPagesSchema.parse([{}]); - }; - assertThrows(actual, Error, "Required"); - }); - await t.step("Missing category", (): void => { - const actual = (): void => { - solutionPagesSchema.parse([ - { - data: { - title: "title", - description: "description", - }, + await t.step("Invalid data", async (t): Promise => { + await t.step("Empty", (): void => { + const actual = (): void => { + solutionPagesSchema.parse([{}]); + }; + assertThrows(actual, Error, "Required"); + }); + await t.step("Missing category", (): void => { + const actual = (): void => { + solutionPagesSchema.parse([ + { + data: { + title: "title", + description: "description", }, - ]); - }; - assertThrows(actual, ZodError, "Required"); - }); + }, + ]); + }; + assertThrows(actual, ZodError, "Required"); }); - }, -); + }); +}); diff --git a/tool/compile-mdx.ts b/tool/compile-mdx.ts index a7d04e0f..a387fd87 100644 --- a/tool/compile-mdx.ts +++ b/tool/compile-mdx.ts @@ -48,11 +48,10 @@ async function run(): Promise { const initialFiles = getSolutions(contentDir); const compiledFiles = compileSolutions(initialFiles); - const promises = []; + const files: VFile[] = []; for await (const file of compiledFiles) { - promises.push(file); + files.push(file); } - const files = await Promise.all(promises); files.sort(sortFiles); lint(files); @@ -149,7 +148,6 @@ async function* compileSolutions( */ const remarkPlugins = [ remarkFrontmatter, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkMdxFrontmatter, // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkPresetLintConsistent, @@ -203,7 +201,7 @@ async function compileSolution(file: VFile): Promise { } async function writeSolutions(solutions: VFile[]): Promise { - const promises = []; + const promises: Promise[] = []; for (const solution of solutions) { promises.push(writeSolution(solution)); } From 43b5bba85c9057174f5fcff1f73741fe361d6ee6 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 8 May 2024 13:39:38 -0500 Subject: [PATCH 09/19] fix: mdx compilation discovery path resolution --- tool/compile-mdx.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tool/compile-mdx.ts b/tool/compile-mdx.ts index a7d04e0f..1c36878e 100644 --- a/tool/compile-mdx.ts +++ b/tool/compile-mdx.ts @@ -1,5 +1,5 @@ import { type CompileOptions, compile } from "@mdx-js/mdx"; -import { dirname, fromFileUrl, join, relative, resolve } from "@std/path"; +import { dirname, fromFileUrl, join, resolve } from "@std/path"; import rehypeMathjax from "rehype-mathjax"; import remarkFrontmatter from "remark-frontmatter"; import remarkLintCheckboxContentIndent from "remark-lint-checkbox-content-indent"; @@ -37,9 +37,9 @@ declare module "vfile" { Deno.chdir(dirname(fromFileUrl(Deno.mainModule))); // Directories for resolve. -const srcDir = "../src" as const; -const contentDir = `${srcDir}/content` as const; -const utilsDir = `${srcDir}/utils` as const; +const srcDir = resolve("..", "src"); +const contentDir = join(srcDir, "content"); +const utilsDir = join(srcDir, "utils"); /** * Compile the MDX files into JS. @@ -77,15 +77,14 @@ async function run(): Promise { */ async function* getSolutions( basePath: string, - currentPath: string = basePath, + currentPath = "", ): AsyncGenerator { - for await (const entry of Deno.readDir(currentPath)) { - const fullPath = join(currentPath, entry.name); - const relPath = relative(basePath, currentPath); - if (entry.isFile && entry.name.match(/mdx?/) !== null) { - yield getSolution(fullPath, entry.name, relPath); + for await (const entry of Deno.readDir(resolve(basePath, currentPath))) { + const fullPath = resolve(basePath, currentPath, entry.name); + if (entry.isFile && entry.name.match(/\.mdx?$/) !== null) { + yield getSolution(fullPath, currentPath, entry.name); } else if (entry.isDirectory) { - yield* getSolutions(basePath, fullPath); + yield* getSolutions(basePath, join(currentPath, entry.name)); } } } @@ -94,14 +93,14 @@ async function* getSolutions( * Get the contents of a file. * * @param fullPath - The full path to the file. - * @param fileName - The name of the file. * @param relPath - The relative path to the file. + * @param fileName - The name of the file. * @returns The file's contents. */ async function getSolution( fullPath: string, + relPath: string, fileName: string, - relPath = ".", ): Promise { const fileContent = await Deno.readTextFile(fullPath); @@ -109,6 +108,7 @@ async function getSolution( value: fileContent, dirname: relPath, basename: fileName, + cwd: fullPath, }); } From 837c0df6475a6aba13daa54c4f354e63871c30cf Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Sun, 5 May 2024 16:58:54 -0500 Subject: [PATCH 10/19] fix: strict csp The csp didn't work right with latest fresh. --- src/utils/csp.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/csp.ts b/src/utils/csp.ts index 28f43243..408724fa 100644 --- a/src/utils/csp.ts +++ b/src/utils/csp.ts @@ -1,7 +1,8 @@ -import { SELF, UNSAFE_INLINE, useCSP } from "$fresh/runtime.ts"; +import { SELF, STRICT_DYNAMIC, UNSAFE_INLINE, useCSP } from "$fresh/runtime.ts"; export function useCsp(): void { useCSP((csp) => { + csp.directives.scriptSrc ??= []; csp.directives.scriptSrcElem ??= []; csp.directives.styleSrc ??= []; csp.directives.styleSrcElem ??= []; @@ -9,9 +10,10 @@ export function useCsp(): void { csp.directives.connectSrc ??= []; csp.directives.manifestSrc ??= []; + csp.directives.scriptSrc.push(STRICT_DYNAMIC); csp.directives.scriptSrcElem.push(SELF, UNSAFE_INLINE); csp.directives.styleSrc.push(SELF); - csp.directives.styleSrcElem.push(SELF, UNSAFE_INLINE); + csp.directives.styleSrcElem.push(SELF, STRICT_DYNAMIC); csp.directives.imgSrc.push(SELF, "data:"); csp.directives.connectSrc.push(SELF); csp.directives.manifestSrc.push(SELF); From a6d93047a28d90f6cc829bb0311147ce0e2939fb Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Sun, 5 May 2024 16:57:50 -0500 Subject: [PATCH 11/19] fix: missing partial island warning Apparently f-client-nav requires the direct child to be a partial. It works fine otherwise, so I hadn't noticed. However, it turns out `f-client-nav`ed islands must be partialled. --- src/routes/_app.tsx | 6 ++++-- src/routes/_layout.tsx | 7 ++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/routes/_app.tsx b/src/routes/_app.tsx index db79db2c..f2a79fba 100644 --- a/src/routes/_app.tsx +++ b/src/routes/_app.tsx @@ -1,4 +1,4 @@ -import { Head, asset } from "$fresh/runtime.ts"; +import { Head, Partial, asset } from "$fresh/runtime.ts"; import type { PageProps } from "$fresh/server.ts"; import type { JSX } from "preact"; import { @@ -71,7 +71,9 @@ export default function App({ Component }: PageProps): JSX.Element { - + + + ); diff --git a/src/routes/_layout.tsx b/src/routes/_layout.tsx index 05a8f29a..af66e98b 100644 --- a/src/routes/_layout.tsx +++ b/src/routes/_layout.tsx @@ -1,4 +1,3 @@ -import { Partial } from "$fresh/runtime.ts"; import type { PageProps } from "$fresh/server.ts"; import type { JSX } from "preact"; import { Footer } from "../components/Footer.tsx"; @@ -16,10 +15,8 @@ import { Chatbot } from "../islands/Chatbot.tsx"; export default function Layout({ Component, url }: PageProps): JSX.Element { return (
- -
- - +
+
From 32bbd15fd690ace6a5cbfbf74bbd52006e13c2cb Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 8 May 2024 14:03:49 -0500 Subject: [PATCH 12/19] chore(deps-dev): bump unified deps --- deno.json | 20 ++++++++++---------- src/content/geothermal/what.mdx | 8 ++++---- tool/compile-mdx.ts | 11 ----------- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/deno.json b/deno.json index a90c24b5..f7f0ba56 100644 --- a/deno.json +++ b/deno.json @@ -42,23 +42,23 @@ "preact/": "https://esm.sh/v135/preact@10.21.0/", "rehype-mathjax": "npm:rehype-mathjax@6.0.0", "remark-frontmatter": "npm:remark-frontmatter@5.0.0", - "remark-lint-checkbox-content-indent": "npm:remark-lint-checkbox-content-indent@4.1.1", - "remark-lint-definition-spacing": "npm:remark-lint-definition-spacing@3.1.1", - "remark-lint-heading-increment": "npm:remark-lint-heading-increment@3.1.1", - "remark-lint-linebreak-style": "npm:remark-lint-linebreak-style@3.1.1", - "remark-lint-no-consecutive-blank-lines": "npm:remark-lint-no-consecutive-blank-lines@4.1.2", - "remark-lint-no-missing-blank-lines": "npm:remark-lint-no-missing-blank-lines@3.1.1", - "remark-lint-no-tabs": "npm:remark-lint-no-tabs@3.1.1", + "remark-lint-checkbox-content-indent": "npm:remark-lint-checkbox-content-indent@5.0.0", + "remark-lint-definition-spacing": "npm:remark-lint-definition-spacing@4.0.0", + "remark-lint-heading-increment": "npm:remark-lint-heading-increment@4.0.0", + "remark-lint-linebreak-style": "npm:remark-lint-linebreak-style@4.0.0", + "remark-lint-no-consecutive-blank-lines": "npm:remark-lint-no-consecutive-blank-lines@5.0.0", + "remark-lint-no-missing-blank-lines": "npm:remark-lint-no-missing-blank-lines@4.0.0", + "remark-lint-no-tabs": "npm:remark-lint-no-tabs@4.0.0", "remark-math": "npm:remark-math@6.0.0", "remark-mdx-frontmatter": "npm:remark-mdx-frontmatter@4.0.0", - "remark-preset-lint-consistent": "npm:remark-preset-lint-consistent@5.1.2", - "remark-preset-lint-recommended": "npm:remark-preset-lint-recommended@6.1.3", + "remark-preset-lint-consistent": "npm:remark-preset-lint-consistent@6.0.0", + "remark-preset-lint-recommended": "npm:remark-preset-lint-recommended@7.0.0", "tailwindcss": "npm:tailwindcss@3.4.1", "tailwindcss/plugin": "npm:tailwindcss@3.4.1/plugin.js", "unified": "npm:unified@11.0.4", "vfile": "npm:vfile@6.0.1", "vfile-matter": "npm:vfile-matter@5.0.0", - "vfile-reporter": "npm:vfile-reporter@8.1.0", + "vfile-reporter": "npm:vfile-reporter@8.1.1", "zod": "https://deno.land/x/zod@v3.22.4/mod.ts" }, "scopes": { diff --git a/src/content/geothermal/what.mdx b/src/content/geothermal/what.mdx index 55f26936..e1e0d147 100644 --- a/src/content/geothermal/what.mdx +++ b/src/content/geothermal/what.mdx @@ -19,7 +19,7 @@ The switch to geothermal is still beginning, but it will be a worthy investment There are four types of geothermal energy solutions. -1. Horizontal loop: Horizontal loop systems are best for properties with more land, as they are bigger and require deeper trenches. -2. Vertical Loop: Vertical loop systems are very narrow and great for residential areas! -3. Closed Loop: Closed loop systems mix water and antifreeze to accommodate cold climates, making them optimal for northern locations. -4. Open Loop: Open loop systems circulate water from an outside source, meaning that they are optimal for properties with a steady water source. +1. Horizontal loop: Horizontal loop systems are best for properties with more land, as they are bigger and require deeper trenches. +2. Vertical Loop: Vertical loop systems are very narrow and great for residential areas! +3. Closed Loop: Closed loop systems mix water and antifreeze to accommodate cold climates, making them optimal for northern locations. +4. Open Loop: Open loop systems circulate water from an outside source, meaning that they are optimal for properties with a steady water source. diff --git a/tool/compile-mdx.ts b/tool/compile-mdx.ts index a387fd87..d66e45ec 100644 --- a/tool/compile-mdx.ts +++ b/tool/compile-mdx.ts @@ -149,23 +149,14 @@ async function* compileSolutions( const remarkPlugins = [ remarkFrontmatter, remarkMdxFrontmatter, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkPresetLintConsistent, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkPresetLintRecommended, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkLintCheckboxContentIndent, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkLintDefinitionSpacing, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkLintHeadingIncrement, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkLintLinebreakStyle, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkLintNoTabs, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkLintNoConsecutiveBlankLines, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkLintNoMissingBlankLines, [remarkMath, { singleDollarTextMath: false } satisfies MathOptions], ] as const satisfies PluggableList; @@ -176,7 +167,6 @@ const rehypePlugins = [rehypeMathjax] as const satisfies PluggableList; const compileOptions = { jsxImportSource: "preact", rehypePlugins, - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkPlugins, } as const satisfies CompileOptions; @@ -189,7 +179,6 @@ const compileOptions = { async function compileSolution(file: VFile): Promise { matter(file); // Extract the frontmatter into `data.matter`. - // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. const compiled = await compile(file, compileOptions); compiled.extname = ".js"; From 819be72bcb0d68c0747f5805014aff5138902385 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 8 May 2024 20:37:38 -0500 Subject: [PATCH 13/19] chore(deps): bump tailwind --- deno.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index f7f0ba56..f1bee03e 100644 --- a/deno.json +++ b/deno.json @@ -34,7 +34,7 @@ "@std/assert": "jsr:@std/assert@^0.220.1", "@std/path": "jsr:@std/path@^0.220.1", "@tailwindcss/forms": "npm:@tailwindcss/forms@0.5.7", - "@tailwindcss/typography": "npm:@tailwindcss/typography@0.5.10", + "@tailwindcss/typography": "npm:@tailwindcss/typography@0.5.13", "idb-keyval": "npm:idb-keyval@6.2.1", "openai": "https://deno.land/x/openai@v4.29.2/mod.ts", "openai/": "https://deno.land/x/openai@v4.29.2/", @@ -53,8 +53,8 @@ "remark-mdx-frontmatter": "npm:remark-mdx-frontmatter@4.0.0", "remark-preset-lint-consistent": "npm:remark-preset-lint-consistent@6.0.0", "remark-preset-lint-recommended": "npm:remark-preset-lint-recommended@7.0.0", - "tailwindcss": "npm:tailwindcss@3.4.1", - "tailwindcss/plugin": "npm:tailwindcss@3.4.1/plugin.js", + "tailwindcss": "npm:tailwindcss@3.4.3", + "tailwindcss/plugin": "npm:tailwindcss@3.4.3/plugin.js", "unified": "npm:unified@11.0.4", "vfile": "npm:vfile@6.0.1", "vfile-matter": "npm:vfile-matter@5.0.0", From ba4ff6417c4c68881acc84a4eb0d7e74d8449a37 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 8 May 2024 20:39:33 -0500 Subject: [PATCH 14/19] chore(deps): bump preact-signals --- deno.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index f1bee03e..b94b787d 100644 --- a/deno.json +++ b/deno.json @@ -29,8 +29,8 @@ "@headlessui/react": "https://esm.sh/v135/*@headlessui/react@1.7.17", "@headlessui/tailwindcss": "npm:@headlessui/tailwindcss@0.2.0", "@mdx-js/mdx": "npm:@mdx-js/mdx@3.0.1", - "@preact/signals": "https://esm.sh/v135/*@preact/signals@1.2.2", - "@preact/signals-core": "https://esm.sh/v135/*@preact/signals-core@1.5.1", + "@preact/signals": "https://esm.sh/v135/*@preact/signals@1.2.3", + "@preact/signals-core": "https://esm.sh/v135/*@preact/signals-core@1.6.0", "@std/assert": "jsr:@std/assert@^0.220.1", "@std/path": "jsr:@std/path@^0.220.1", "@tailwindcss/forms": "npm:@tailwindcss/forms@0.5.7", @@ -63,7 +63,7 @@ }, "scopes": { "https://esm.sh/v135/": { - "@preact/signals-react": "https://esm.sh/v135/*@preact/signals@1.2.2", + "@preact/signals-react": "https://esm.sh/v135/*@preact/signals@1.2.3", "client-only": "https://esm.sh/v135/client-only@0.0.1", "react-dom": "https://esm.sh/v135/preact@10.21.0/compat", "react": "https://esm.sh/v135/preact@10.21.0/compat", From bf2bd118448d4b04497db168015421959fe7365b Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 8 May 2024 20:40:08 -0500 Subject: [PATCH 15/19] chore(deps): bump deno std modules --- deno.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deno.json b/deno.json index b94b787d..39d0d4a2 100644 --- a/deno.json +++ b/deno.json @@ -31,8 +31,8 @@ "@mdx-js/mdx": "npm:@mdx-js/mdx@3.0.1", "@preact/signals": "https://esm.sh/v135/*@preact/signals@1.2.3", "@preact/signals-core": "https://esm.sh/v135/*@preact/signals-core@1.6.0", - "@std/assert": "jsr:@std/assert@^0.220.1", - "@std/path": "jsr:@std/path@^0.220.1", + "@std/assert": "jsr:@std/assert@^0.224.0", + "@std/path": "jsr:@std/path@^0.224.0", "@tailwindcss/forms": "npm:@tailwindcss/forms@0.5.7", "@tailwindcss/typography": "npm:@tailwindcss/typography@0.5.13", "idb-keyval": "npm:idb-keyval@6.2.1", From e4de0eca1457e983edd5c00f525f06ee5398d85d Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 8 May 2024 20:40:20 -0500 Subject: [PATCH 16/19] chore(deps): bump openai --- deno.json | 4 ++-- src/utils/openai/references.ts | 6 +----- src/utils/openai/schemas.ts | 9 ++++++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/deno.json b/deno.json index 39d0d4a2..3928e210 100644 --- a/deno.json +++ b/deno.json @@ -36,8 +36,8 @@ "@tailwindcss/forms": "npm:@tailwindcss/forms@0.5.7", "@tailwindcss/typography": "npm:@tailwindcss/typography@0.5.13", "idb-keyval": "npm:idb-keyval@6.2.1", - "openai": "https://deno.land/x/openai@v4.29.2/mod.ts", - "openai/": "https://deno.land/x/openai@v4.29.2/", + "openai": "https://deno.land/x/openai@v4.42.0/mod.ts", + "openai/": "https://deno.land/x/openai@v4.42.0/", "preact": "https://esm.sh/v135/preact@10.21.0", "preact/": "https://esm.sh/v135/preact@10.21.0/", "rehype-mathjax": "npm:rehype-mathjax@6.0.0", diff --git a/src/utils/openai/references.ts b/src/utils/openai/references.ts index d5fe9206..50a5e784 100644 --- a/src/utils/openai/references.ts +++ b/src/utils/openai/references.ts @@ -1,9 +1,5 @@ -import type { - Annotation, - Message, - TextContentBlock, -} from "openai/resources/beta/threads/messages/messages.ts"; import { getFileData } from "../../sdk/chat/references.ts"; +import type { Annotation, Message, TextContentBlock } from "./schemas.ts"; type AnnotationReplacement = { regex: RegExp; citation: string }; diff --git a/src/utils/openai/schemas.ts b/src/utils/openai/schemas.ts index 778931da..db0fff82 100644 --- a/src/utils/openai/schemas.ts +++ b/src/utils/openai/schemas.ts @@ -1,4 +1,4 @@ -import type { Message } from "openai/resources/beta/threads/messages/messages.ts"; +import type { Message } from "openai/resources/beta/threads/messages.ts"; import type { Thread as OThread } from "openai/resources/beta/threads/threads.ts"; import type { FileObject as OFileObject } from "openai/resources/mod.ts"; import { z } from "zod"; @@ -35,5 +35,8 @@ export const chatThreadSchema = z.custom( (val) => z.object({}).array().safeParse(val).success, ); -export type { Message } from "openai/resources/beta/threads/messages/messages.ts"; -export type { TextContentBlock } from "openai/resources/beta/threads/messages/messages.ts"; +export type { + Message, + Annotation, + TextContentBlock, +} from "openai/resources/beta/threads/messages.ts"; From abeb5b0418bba6f0bc1f4000ec7c72a472ba82f4 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 8 May 2024 20:40:28 -0500 Subject: [PATCH 17/19] chore(deps): bump zod --- deno.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.json b/deno.json index 3928e210..a46de18c 100644 --- a/deno.json +++ b/deno.json @@ -59,7 +59,7 @@ "vfile": "npm:vfile@6.0.1", "vfile-matter": "npm:vfile-matter@5.0.0", "vfile-reporter": "npm:vfile-reporter@8.1.1", - "zod": "https://deno.land/x/zod@v3.22.4/mod.ts" + "zod": "https://deno.land/x/zod@v3.23.7/mod.ts" }, "scopes": { "https://esm.sh/v135/": { From 59baba81c2b0d7a51b82a5214a835c863ad51ed9 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Thu, 9 May 2024 10:19:51 -0500 Subject: [PATCH 18/19] refactor: use polling utilities I gave up on streaming for now, but this is still a nice simplification. --- deno.json | 4 ++-- src/utils/openai/assistant.ts | 17 +---------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/deno.json b/deno.json index a46de18c..ab98ac66 100644 --- a/deno.json +++ b/deno.json @@ -36,8 +36,8 @@ "@tailwindcss/forms": "npm:@tailwindcss/forms@0.5.7", "@tailwindcss/typography": "npm:@tailwindcss/typography@0.5.13", "idb-keyval": "npm:idb-keyval@6.2.1", - "openai": "https://deno.land/x/openai@v4.42.0/mod.ts", - "openai/": "https://deno.land/x/openai@v4.42.0/", + "openai": "https://deno.land/x/openai@v4.43.0/mod.ts", + "openai/": "https://deno.land/x/openai@v4.43.0/", "preact": "https://esm.sh/v135/preact@10.21.0", "preact/": "https://esm.sh/v135/preact@10.21.0/", "rehype-mathjax": "npm:rehype-mathjax@6.0.0", diff --git a/src/utils/openai/assistant.ts b/src/utils/openai/assistant.ts index 4bdb895a..72be6cb5 100644 --- a/src/utils/openai/assistant.ts +++ b/src/utils/openai/assistant.ts @@ -19,25 +19,10 @@ export async function* ask( role: "user", content: q, }); - let run = await client.beta.threads.runs.create(thread_id, { + await client.beta.threads.runs.createAndPoll(thread_id, { assistant_id, }); - // TODO(lishaduck): Poll on the client - while ( - run.status === "in_progress" || - run.status === "queued" || - run.status === "requires_action" - ) { - // Make sure we don't poll too frequently. - // deno-lint-ignore no-await-in-loop - await new Promise((resolve) => setTimeout(resolve, 1000)); - - // Polling is required, as streaming is not yet supported. - // deno-lint-ignore no-await-in-loop - run = await client.beta.threads.runs.retrieve(thread_id, run.id); - } - for await (const message of client.beta.threads.messages.list(thread_id)) { yield message; } From 26b812ed794a441b690e44a88660c2f2da67b6c7 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Thu, 9 May 2024 10:47:20 -0500 Subject: [PATCH 19/19] fix: lh csp assertions --- src/utils/csp.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/utils/csp.ts b/src/utils/csp.ts index 408724fa..c99c34b2 100644 --- a/src/utils/csp.ts +++ b/src/utils/csp.ts @@ -1,4 +1,10 @@ -import { SELF, STRICT_DYNAMIC, UNSAFE_INLINE, useCSP } from "$fresh/runtime.ts"; +import { + NONE, + SELF, + STRICT_DYNAMIC, + UNSAFE_INLINE, + useCSP, +} from "$fresh/runtime.ts"; export function useCsp(): void { useCSP((csp) => { @@ -9,13 +15,15 @@ export function useCsp(): void { csp.directives.imgSrc ??= []; csp.directives.connectSrc ??= []; csp.directives.manifestSrc ??= []; + csp.directives.baseUri ??= []; - csp.directives.scriptSrc.push(STRICT_DYNAMIC); + csp.directives.scriptSrc.push(STRICT_DYNAMIC, UNSAFE_INLINE); csp.directives.scriptSrcElem.push(SELF, UNSAFE_INLINE); csp.directives.styleSrc.push(SELF); csp.directives.styleSrcElem.push(SELF, STRICT_DYNAMIC); csp.directives.imgSrc.push(SELF, "data:"); csp.directives.connectSrc.push(SELF); csp.directives.manifestSrc.push(SELF); + csp.directives.baseUri.push(NONE); }); }