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