Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@date-fns/utc": "1.2.0",
"@monkeytype/contracts": "workspace:*",
"@monkeytype/funbox": "workspace:*",
"@monkeytype/schemas": "workspace:*",
"@monkeytype/util": "workspace:*",
"@ts-rest/core": "3.52.1",
"@ts-rest/express": "3.52.1",
Expand Down Expand Up @@ -64,7 +65,6 @@
"devDependencies": {
"@monkeytype/eslint-config": "workspace:*",
"@monkeytype/oxlint-config": "workspace:*",
"@monkeytype/schemas": "workspace:*",
"@monkeytype/typescript-config": "workspace:*",
"@redocly/cli": "2.0.5",
"@types/bcrypt": "5.0.2",
Expand Down
12 changes: 6 additions & 6 deletions docker/frontend/updateConfig.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh
cd /usr/share/nginx/html
echo "replace firebase config appid: ${FIREBASE_APPID}"
sed -i "s/###FIREBASE_APIKEY###/${FIREBASE_APIKEY}/g" js/firebase.*.js
sed -i "s/###FIREBASE_AUTHDOMAIN###/${FIREBASE_AUTHDOMAIN}/g" js/firebase.*.js
sed -i "s/###FIREBASE_PROJECTID###/${FIREBASE_PROJECTID}/g" js/firebase.*.js
sed -i "s/###FIREBASE_STORAGEBUCKET###/${FIREBASE_STORAGEBUCKET}/g" js/firebase.*.js
sed -i "s/###FIREBASE_MESSAGINGSENDERID###/${FIREBASE_MESSAGINGSENDERID}/g" js/firebase.*.js
sed -i "s/###FIREBASE_APPID###/${FIREBASE_APPID}/g" js/firebase.*.js
sed -i "s/###FIREBASE_APIKEY###/${FIREBASE_APIKEY}/g" js/firebase-config-live.*.js
sed -i "s/###FIREBASE_AUTHDOMAIN###/${FIREBASE_AUTHDOMAIN}/g" js/firebase-config-live.*.js
sed -i "s/###FIREBASE_PROJECTID###/${FIREBASE_PROJECTID}/g" js/firebase-config-live.*.js
sed -i "s/###FIREBASE_STORAGEBUCKET###/${FIREBASE_STORAGEBUCKET}/g" js/firebase-config-live.*.js
sed -i "s/###FIREBASE_MESSAGINGSENDERID###/${FIREBASE_MESSAGINGSENDERID}/g" js/firebase-config-live.*.js
sed -i "s/###FIREBASE_APPID###/${FIREBASE_APPID}/g" js/firebase-config-live.*.js


echo "use backend url ${MONKEYTYPE_BACKENDURL}"
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@fortawesome/fontawesome-free": "5.15.4",
"@monkeytype/eslint-config": "workspace:*",
"@monkeytype/oxlint-config": "workspace:*",
"@monkeytype/schemas": "workspace:*",
"@monkeytype/typescript-config": "workspace:*",
"@types/canvas-confetti": "1.4.3",
"@types/chartjs-plugin-trendline": "1.0.1",
Expand Down Expand Up @@ -80,6 +79,7 @@
"@date-fns/utc": "1.2.0",
"@monkeytype/contracts": "workspace:*",
"@monkeytype/funbox": "workspace:*",
"@monkeytype/schemas": "workspace:*",
"@monkeytype/util": "workspace:*",
"@sentry/browser": "9.14.0",
"@sentry/vite-plugin": "3.3.1",
Expand Down
17 changes: 14 additions & 3 deletions frontend/src/ts/test/pace-caret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type Settings = {
timeout: NodeJS.Timeout | null;
};

let startTimestamp = 0;

export let settings: Settings | null = null;

export const caret = new Caret(
Expand Down Expand Up @@ -129,7 +131,7 @@ export async function init(): Promise<void> {
};
}

export async function update(duration: number): Promise<void> {
export async function update(expectedStepEnd: number): Promise<void> {
if (settings === null || !TestState.isActive || TestState.resultVisible) {
return;
}
Expand All @@ -141,6 +143,10 @@ export async function update(duration: number): Promise<void> {
incrementLetterIndex();

try {
const now = performance.now();
const absoluteStepEnd = startTimestamp + expectedStepEnd;
const duration = absoluteStepEnd - now;

caret.goTo({
wordIndex: settings.currentWordIndex,
letterIndex: settings.currentLetterIndex,
Expand All @@ -152,11 +158,13 @@ export async function update(duration: number): Promise<void> {
easing: "linear",
},
});

// Normal case - schedule next step
settings.timeout = setTimeout(() => {
update((settings?.spc ?? 0) * 1000).catch(() => {
update(expectedStepEnd + (settings?.spc ?? 0) * 1000).catch(() => {
settings = null;
});
}, duration);
}, Math.max(0, duration));
} catch (e) {
console.error(e);
caret.hide();
Expand All @@ -169,6 +177,7 @@ export function reset(): void {
clearTimeout(settings.timeout);
}
settings = null;
startTimestamp = 0;
}

function incrementLetterIndex(): void {
Expand Down Expand Up @@ -243,6 +252,8 @@ export function handleSpace(correct: boolean, currentWord: string): void {
}

export function start(): void {
const now = performance.now();
startTimestamp = now;
void update((settings?.spc ?? 0) * 1000);
}

Expand Down
9 changes: 6 additions & 3 deletions frontend/src/ts/utils/caret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,10 @@ export class Caret {
// we also clamp the letterIndex to be within the range of actual letters
// anything beyond just goes to the edge of the word
let side: "beforeLetter" | "afterLetter" = "beforeLetter";
if (options.letterIndex >= letters.length) {
if (
options.letterIndex >= letters.length ||
(Config.blindMode && options.letterIndex >= wordText.length)
) {
side = "afterLetter";
options.letterIndex = letters.length - 1;
}
Expand Down Expand Up @@ -405,9 +408,9 @@ export class Caret {
options.isDirectionReversed
);

//if the letter is not visible, use the closest visible letter (but only for full width carets)
//if the letter is not visible, use the closest visible letter
const isLetterVisible = options.letter.offsetWidth > 0;
if (!isLetterVisible && this.isFullWidth()) {
if (!isLetterVisible) {
const letters = options.word.querySelectorAll<HTMLElement>("letter");
if (letters.length === 0) {
throw new Error("Caret getLeftTopWidth: no letters found in word");
Expand Down
62 changes: 62 additions & 0 deletions frontend/static/layouts/gallium_nl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"keymapShowTopRow": false,
"type": "ansi",
"keys": {
"row1": [
["`", "~"],
["1", "!"],
["2", "@"],
["3", "#"],
["4", "$"],
["5", "%"],
["6", "^"],
["7", "&"],
["8", "*"],
["9", "("],
["0", ")"],
["-", "_"],
["=", "+"]
],
"row2": [
["b", "B"],
["l", "L"],
["d", "D"],
["c", "C"],
["v", "V"],
["y", "Y"],
["p", "P"],
["u", "U"],
["o", "O"],
[",", "<"],
["[", "{"],
["]", "}"],
["\\", "|"]
],
"row3": [
["n", "N"],
["r", "R"],
["t", "T"],
["s", "S"],
["w", "W"],
["f", "F"],
["h", "H"],
["e", "E"],
["a", "A"],
["i", "I"],
["/", "?"]
],
"row4": [
["x", "X"],
["q", "Q"],
["m", "M"],
["g", "G"],
["j", "J"],
["z", "Z"],
["k", "K"],
["'", "\""],
[";", ":"],
[".", ">"]
],
"row5": [[" "]]
}
}
4 changes: 3 additions & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
"oxlint": "oxlint .",
"lint": "npm run oxlint && npm run eslint"
},
"dependencies": {
"@monkeytype/schemas": "workspace:*"
},
"peerDependencies": {
"@ts-rest/core": "3.52.1",
"zod": "3.23.8"
},
"devDependencies": {
"@monkeytype/eslint-config": "workspace:*",
"@monkeytype/schemas": "workspace:*",
"@monkeytype/tsup-config": "workspace:*",
"@monkeytype/typescript-config": "workspace:*",
"eslint": "8.57.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/funbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
},
"devDependencies": {
"@monkeytype/eslint-config": "workspace:*",
"@monkeytype/schemas": "workspace:*",
"@monkeytype/tsup-config": "workspace:*",
"@monkeytype/typescript-config": "workspace:*",
"eslint": "8.57.1",
Expand All @@ -24,6 +23,7 @@
"vitest": "3.2.4"
},
"dependencies": {
"@monkeytype/schemas": "workspace:*",
"@monkeytype/util": "workspace:*"
},
"exports": {
Expand Down
1 change: 1 addition & 0 deletions packages/schemas/src/layouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const LayoutNameSchema = z.enum(
"gallium_angle",
"gallium_v2",
"gallium_v2_matrix",
"gallium_nl",
"maya",
"gallaya_angle_ansi",
"gallaya_angle_iso",
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading