feat: prepare vim-sudoku for unified API implementation

- Archive previous implementation attempt (src -> src_failed)
- Create comprehensive IMPLEMENTATION_PLAN.md with phased approach
- Create IMPLEMENTATION.md to track implementation progress
- Update example app to match vim-maze patterns:
  - Simplify UI to desktop-only (no mobile support)
  - Add score metrics display (time, keystrokes, final score)
  - Update instructions for sudoku-specific keys (hjkl, i for edit)
  - Remove unnecessary mobile hooks

Phase 5 complete. Ready to begin Phase 10 (Setup & Core Types).
This commit is contained in:
2025-10-22 18:08:33 +01:00
parent d0a51d7079
commit 9292b83dd0
25 changed files with 368 additions and 85 deletions
+45
View File
@@ -0,0 +1,45 @@
import { useState, useEffect, useRef } from 'react';
import type { TimerManager } from './types';
export function useTimer(): TimerManager {
const [timeValue, setTimeValue] = useState<number>(0);
const intervalRef = useRef<NodeJS.Timeout | null>(null);
const startTimeRef = useRef<number>(0);
const startTimer = () => {
if (intervalRef.current) return;
startTimeRef.current = Date.now() - timeValue;
intervalRef.current = setInterval(() => {
setTimeValue(Date.now() - startTimeRef.current);
}, 100);
};
const stopTimer = () => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
};
const resetTimer = () => {
stopTimer();
setTimeValue(0);
startTimeRef.current = 0;
};
useEffect(() => {
return () => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
}
};
}, []);
return {
timeValue,
startTimer,
stopTimer,
resetTimer
};
}