Skip to content

Commit dd32e68

Browse files
authored
Merge branch 'master' into quote-favorite
2 parents 45b0ed8 + 73e9a6a commit dd32e68

83 files changed

Lines changed: 1779 additions & 2050 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

frontend/__tests__/utils/url-handler.spec.ts renamed to frontend/__tests__/controllers/url-handler.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import * as Notifications from "../../src/ts/stores/notifications";
66
import * as TestLogic from "../../src/ts/test/test-logic";
77
import * as TestState from "../../src/ts/test/test-state";
88
import * as Misc from "../../src/ts/utils/misc";
9-
import { loadTestSettingsFromUrl } from "../../src/ts/utils/url-handler";
109
import { FunboxName } from "@monkeytype/schemas/configs";
1110
import { CustomTextSettings } from "@monkeytype/schemas/results";
11+
import { loadTestSettingsFromUrl } from "../../src/ts/controllers/url-handler";
1212

1313
//mock modules to avoid dependencies
1414
vi.mock("../../src/ts/test/test-logic", () => ({

frontend/__tests__/root/config.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, it, expect, beforeEach, afterAll, vi } from "vitest";
22
import * as Config from "../../src/ts/config";
33
import * as Misc from "../../src/ts/utils/misc";
4+
import * as Env from "../../src/ts/utils/env";
45
import {
56
ConfigKey,
67
Config as ConfigType,
@@ -14,7 +15,7 @@ import * as Notifications from "../../src/ts/stores/notifications";
1415
const { replaceConfig, getConfig } = Config.__testing;
1516

1617
describe("Config", () => {
17-
const isDevEnvironmentMock = vi.spyOn(Misc, "isDevEnvironment");
18+
const isDevEnvironmentMock = vi.spyOn(Env, "isDevEnvironment");
1819
beforeEach(() => {
1920
isDevEnvironmentMock.mockClear();
2021
replaceConfig({});

frontend/__tests__/utils/misc.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, it, expect, vi } from "vitest";
22
import {
3-
getErrorMessage,
43
isObject,
54
escapeHTML,
65
promiseWithResolvers,
@@ -10,6 +9,7 @@ import {
109
removeLanguageSize,
1110
} from "../../src/ts/utils/strings";
1211
import { Language } from "@monkeytype/schemas/languages";
12+
import { getErrorMessage } from "../../src/ts/utils/error";
1313

1414
describe("misc.ts", () => {
1515
describe("getLanguageDisplayString", () => {

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"chart.js": "3.7.1",
4949
"chartjs-adapter-date-fns": "3.0.0",
5050
"chartjs-plugin-annotation": "2.2.1",
51-
"chartjs-plugin-trendline": "1.0.2",
51+
"chartjs-plugin-trendline": "3.2.0",
5252
"clsx": "2.1.1",
5353
"color-blend": "4.0.0",
5454
"damerau-levenshtein": "1.0.8",

frontend/scripts/import-tree.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,57 @@ for (const entry of entryPoints) {
282282
printTree(entry, new Set([entry]), "", true, true);
283283
if (entryPoints.length > 1) console.log();
284284
}
285+
286+
// --- Summary ---
287+
288+
let totalDirect = 0;
289+
let totalTransitive = 0;
290+
const uniqueDirect = new Set<string>();
291+
const uniqueTransitive = new Set<string>();
292+
let maxDirect = 0;
293+
let maxDirectFile = "";
294+
let maxTransitive = 0;
295+
let maxTransitiveFile = "";
296+
let maxDepthSeen = 0;
297+
let maxDepthFile = "";
298+
299+
for (const entry of entryPoints) {
300+
const info = cache.get(entry);
301+
if (!info) continue;
302+
totalDirect += info.directImports.length;
303+
totalTransitive += info.totalReachable;
304+
for (const dep of info.directImports) {
305+
uniqueDirect.add(dep);
306+
}
307+
for (const dep of getAllReachable(entry, new Set())) {
308+
uniqueTransitive.add(dep);
309+
}
310+
if (info.directImports.length > maxDirect) {
311+
maxDirect = info.directImports.length;
312+
maxDirectFile = entry;
313+
}
314+
if (info.totalReachable > maxTransitive) {
315+
maxTransitive = info.totalReachable;
316+
maxTransitiveFile = entry;
317+
}
318+
if (info.maxDepth > maxDepthSeen) {
319+
maxDepthSeen = info.maxDepth;
320+
maxDepthFile = entry;
321+
}
322+
}
323+
324+
console.log(`${c.dim}───────────────────────────${c.reset}`);
325+
console.log(`Target: ${c.bold}${displayPath(resolved)}${c.reset}`);
326+
console.log(`Total direct: ${c.bold}${totalDirect}${c.reset}`);
327+
console.log(`Total transitive: ${c.bold}${totalTransitive}${c.reset}`);
328+
console.log(`Unique direct: ${c.bold}${uniqueDirect.size}${c.reset}`);
329+
console.log(`Unique transitive: ${c.bold}${uniqueTransitive.size}${c.reset}`);
330+
console.log(
331+
`Max direct: ${c.bold}${maxDirect}${c.reset} ${c.dim}(${displayPath(maxDirectFile)})${c.reset}`,
332+
);
333+
console.log(
334+
`Max transitive: ${c.bold}${maxTransitive}${c.reset} ${c.dim}(${displayPath(maxTransitiveFile)})${c.reset}`,
335+
);
336+
console.log(
337+
`Max depth: ${c.bold}${maxDepthSeen}${c.reset} ${c.dim}(${displayPath(maxDepthFile)})${c.reset}`,
338+
);

frontend/src/ts/auth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
showErrorNotification,
3333
showSuccessNotification,
3434
} from "./stores/notifications";
35-
import { createErrorMessage } from "./utils/misc";
35+
import { createErrorMessage } from "./utils/error";
3636

3737
export const gmailProvider = new GoogleAuthProvider();
3838
export const githubProvider = new GithubAuthProvider();

frontend/src/ts/commandline/commandline-metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import * as ManualRestart from "../test/manual-restart-tracker";
88
import { areUnsortedArraysEqual } from "../utils/arrays";
99
import Config from "../config";
1010
import { get as getTypingSpeedUnit } from "../utils/typing-speed-units";
11-
import { Validation } from "../elements/input-validation";
1211
import { getActivePage } from "../signals/core";
1312
import { Fonts } from "../constants/fonts";
1413
import { KnownFontName } from "@monkeytype/schemas/fonts";
1514
import * as UI from "../ui";
1615
import { typedKeys } from "../utils/misc";
16+
import { Validation } from "../types/validation";
1717

1818
type ConfigKeysWithoutCommands =
1919
| "minWpmCustomSpeed"

frontend/src/ts/commandline/commandline.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ import { areSortedArraysEqual, areUnsortedArraysEqual } from "../utils/arrays";
1818
import { parseIntOptional } from "../utils/numbers";
1919
import { debounce } from "throttle-debounce";
2020
import { intersect } from "@monkeytype/util/arrays";
21-
import {
22-
createInputEventHandler,
23-
ValidationResult,
24-
} from "../elements/input-validation";
21+
import { createInputEventHandler } from "../elements/input-validation";
2522
import { isInputElementFocused } from "../input/input-element";
2623
import { qs } from "../utils/dom";
2724
import { ConfigKey } from "@monkeytype/schemas/configs";
@@ -32,6 +29,7 @@ import {
3229
hideModalAndClearChain as storeClearChain,
3330
isModalOpen,
3431
} from "../stores/modals";
32+
import { ValidationResult } from "../types/validation";
3533

3634
type CommandlineMode = "search" | "input";
3735
type InputModeParams = {
@@ -125,7 +123,7 @@ export function show(
125123
if (exists) {
126124
showLoaderBar();
127125
subgroupOverride = await CommandlineLists.getList(
128-
overrideStringOrGroup,
126+
overrideStringOrGroup as CommandlineLists.ListsObjectKeys,
129127
);
130128
hideLoaderBar();
131129
} else {

frontend/src/ts/commandline/lists.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import LoadChallengeCommands, {
1717
} from "./lists/load-challenge";
1818

1919
import Config, { applyConfigFromJson, setConfig } from "../config";
20-
import * as Misc from "../utils/misc";
20+
import * as getErrorMessage from "../utils/error";
2121
import * as JSONData from "../utils/json-data";
2222
import { randomizeTheme } from "../controllers/theme-controller";
2323
import * as CustomTextPopup from "../modals/custom-text";
@@ -47,7 +47,10 @@ challengesPromise
4747
})
4848
.catch((e: unknown) => {
4949
console.error(
50-
Misc.createErrorMessage(e, "Failed to update challenges commands"),
50+
getErrorMessage.createErrorMessage(
51+
e,
52+
"Failed to update challenges commands",
53+
),
5154
);
5255
});
5356

frontend/src/ts/commandline/lists/themes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Command, CommandsSubgroup } from "../types";
55
import { ThemesList, ThemeWithName } from "../../constants/themes";
66
import { not } from "@monkeytype/util/predicates";
77
import * as ConfigEvent from "../../observables/config-event";
8-
import * as Misc from "../../utils/misc";
8+
import * as getErrorMessage from "../../utils/error";
99

1010
const isFavorite = (theme: ThemeWithName): boolean =>
1111
Config.favThemes.includes(theme.name);
@@ -83,7 +83,10 @@ ConfigEvent.subscribe(({ key }) => {
8383
update(ThemesList);
8484
} catch (e: unknown) {
8585
console.error(
86-
Misc.createErrorMessage(e, "Failed to update themes commands"),
86+
getErrorMessage.createErrorMessage(
87+
e,
88+
"Failed to update themes commands",
89+
),
8790
);
8891
}
8992
}

0 commit comments

Comments
 (0)