Skip to content

Commit 6161fdb

Browse files
authored
chore: add solid dev tools (@fehmer) (monkeytypegame#7660)
1 parent 5af1eed commit 6161fdb

File tree

9 files changed

+374
-5
lines changed

9 files changed

+374
-5
lines changed

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@monkeytype/util": "workspace:*",
3333
"@sentry/browser": "9.14.0",
3434
"@sentry/vite-plugin": "3.3.1",
35+
"@solid-devtools/overlay": "0.33.5",
3536
"@solid-primitives/refs": "1.1.2",
3637
"@solid-primitives/transition-group": "1.1.2",
3738
"@solidjs/meta": "0.29.4",
@@ -106,6 +107,7 @@
106107
"oxlint-tsgolint": "0.14.2",
107108
"postcss": "8.5.8",
108109
"sass": "1.70.0",
110+
"solid-devtools": "0.34.5",
109111
"solid-js": "1.9.10",
110112
"subset-font": "2.3.0",
111113
"tailwindcss": "4.1.18",

frontend/src/ts/components/core/DevTools.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type JSXElement, lazy, Suspense } from "solid-js";
1+
import { JSXElement, lazy, onMount, Suspense } from "solid-js";
22

33
let DevComponents: (() => JSXElement) | undefined;
44

@@ -13,10 +13,27 @@ if (import.meta.env.DEV) {
1313
default: m.DevOptionsModal,
1414
})),
1515
);
16+
17+
const LazySolidDevtoolsOverlay = lazy(async () =>
18+
import("@solid-devtools/overlay").then((m) => ({
19+
default: () => {
20+
onMount(() => {
21+
m.attachDevtoolsOverlay({
22+
defaultOpen: true,
23+
noPadding: true,
24+
});
25+
});
26+
27+
return null;
28+
},
29+
})),
30+
);
31+
1632
DevComponents = () => (
1733
<Suspense>
1834
<LazyQueryDevtools />
1935
<LazyDevOptionsModal />
36+
<LazySolidDevtoolsOverlay />
2037
</Suspense>
2138
);
2239
}

frontend/src/ts/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//enable solidjs-devtools
2+
import "solid-devtools";
3+
14
import "./event-handlers/global";
25
import "./event-handlers/keymap";
36
import "./event-handlers/test";

frontend/src/ts/pages/account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ async function fillContent(): Promise<void> {
544544
histogramChartData.push(0);
545545
}
546546
}
547-
(histogramChartData[bucket] as number)++;
547+
(histogramChartData[bucket] as number) += 1;
548548

549549
let tt = 0;
550550
if (

frontend/src/ts/test/funbox/funbox-functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CharDistribution {
8383
public addChar(char: string): void {
8484
this.count++;
8585
if (char in this.chars) {
86-
(this.chars[char] as number)++;
86+
(this.chars[char] as number) += 1;
8787
} else {
8888
this.chars[char] = 1;
8989
}

frontend/src/ts/test/test-input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ export function pushMissedWord(word: string): void {
511511
if (!Object.keys(missedWords).includes(word)) {
512512
missedWords[word] = 1;
513513
} else {
514-
(missedWords[word] as number)++;
514+
(missedWords[word] as number) += 1;
515515
}
516516
}
517517

frontend/src/ts/utils/search-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const buildSearchService = <T>(
9898
internalDocument.termFrequencies[stemmedToken] = 0;
9999
}
100100

101-
(internalDocument.termFrequencies[stemmedToken] as number)++;
101+
(internalDocument.termFrequencies[stemmedToken] as number) += 1;
102102
maxTermFrequency = Math.max(
103103
maxTermFrequency,
104104
internalDocument.termFrequencies[stemmedToken] as number,

frontend/vite.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { VitePWA } from "vite-plugin-pwa";
2626
import { sentryVitePlugin } from "@sentry/vite-plugin";
2727
import { KnownFontName } from "@monkeytype/schemas/fonts";
2828
import solidPlugin from "vite-plugin-solid";
29+
import devtools from "solid-devtools/vite";
2930
import tailwindcss from "@tailwindcss/vite";
3031

3132
function getFontsConfig(): string {
@@ -105,7 +106,11 @@ function getPlugins({
105106
languageHashes({ skip: isDevelopment }),
106107
injectHTML() as PluginOption,
107108
tailwindcss(),
109+
108110
solidPlugin(),
111+
devtools({
112+
autoname: true,
113+
}),
109114
];
110115

111116
const devPlugins: PluginOption[] = [

0 commit comments

Comments
 (0)