react-chess-core 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/features/analysis/core/AnalysisBoardCore.d.ts +8 -2
- package/dist/features/chessboard/ChessboardDnDProvider.d.ts +9 -0
- package/dist/features/chessboard/boardThemes.d.ts +19 -0
- package/dist/features/chessboard/chessboardTheme.d.ts +6 -2
- package/dist/features/chessboard/index.d.ts +2 -0
- package/dist/features/engine/AnalysisEngineContext.d.ts +22 -0
- package/dist/features/engine/index.d.ts +1 -0
- package/dist/features/engine/types.d.ts +10 -0
- package/dist/features/engine/useAnalysisEngine.d.ts +2 -0
- package/dist/features/navigation/PlyNavigation.d.ts +1 -1
- package/dist/features/navigation/index.d.ts +2 -0
- package/dist/features/navigation/positionKeyboardNav.d.ts +12 -0
- package/dist/features/navigation/types.d.ts +5 -0
- package/dist/features/navigation/usePositionKeyboardNav.d.ts +12 -0
- package/dist/features/training/expectedMoveDrop.d.ts +24 -0
- package/dist/features/training/index.d.ts +4 -0
- package/dist/features/training/miss/index.d.ts +5 -0
- package/dist/features/training/miss/missDisplay.d.ts +16 -0
- package/dist/features/training/miss/refutation.d.ts +19 -0
- package/dist/features/training/miss/useMissBoard.d.ts +28 -0
- package/dist/features/training/miss/useMissRefutation.d.ts +3 -0
- package/dist/features/training/miss/useMissSequence.d.ts +10 -0
- package/dist/features/training/uciFromDrop.d.ts +3 -0
- package/dist/features/training/useBoardRevision.d.ts +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +2406 -89
- package/dist/index.js +2436 -87
- package/dist/stories/AnalysisBoard.stories.d.ts +9 -0
- package/dist/stories/analysisFixtures.d.ts +5 -0
- package/dist/stories/regressions/StockfishAnalysisRegressions.stories.d.ts +7 -0
- package/dist/stories/regressions/fixtures.d.ts +17 -0
- package/dist/stories/regressions/regressionAnalysisContext.d.ts +6 -0
- package/dist/stories/storybookLayout.d.ts +4 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ npm run build
|
|
|
7
7
|
|
|
8
8
|
Shared **chessboard** (theme + `HighlightChessboard`) and **browser Stockfish** utilities. Used by `react-chess-puzzle-kit` and (planned) `react-chess-explorer`.
|
|
9
9
|
|
|
10
|
+
Used in production at [endchess.com](https://endchess.com).
|
|
11
|
+
|
|
10
12
|
Storybook: `npm run storybook` → http://localhost:6007
|
|
11
13
|
|
|
12
14
|
---
|
|
@@ -4,6 +4,11 @@ import { AnalysisEngineOptions } from '../../engine/types';
|
|
|
4
4
|
import { AnalysisBoardModel, UseAnalysisBoardModelArgs } from './useAnalysisBoardModel';
|
|
5
5
|
export type AnalysisBoardCoreProps = UseAnalysisBoardModelArgs & {
|
|
6
6
|
engine?: AnalysisEngineOptions;
|
|
7
|
+
/**
|
|
8
|
+
* Register ArrowLeft/ArrowRight/Home/End shortcuts while analysis is open.
|
|
9
|
+
* Default true.
|
|
10
|
+
*/
|
|
11
|
+
keyboardNav?: boolean;
|
|
7
12
|
/** Host-owned shell (modal, page layout, etc.). */
|
|
8
13
|
renderContainer: (props: AnalysisContainerRenderProps) => React.ReactNode;
|
|
9
14
|
/** Host-owned grid/placement of board + sidebar (no library default). */
|
|
@@ -15,14 +20,15 @@ export type AnalysisBoardCoreProps = UseAnalysisBoardModelArgs & {
|
|
|
15
20
|
* Analysis logic + composition only: hook, board node, sidebar/engine slots.
|
|
16
21
|
* No layout divs — use {@link renderMain} (e.g. `AnalysisBoardLayout` from `analysis/defaults` or a host layout).
|
|
17
22
|
*/
|
|
18
|
-
export declare const AnalysisBoardCore: ({ renderContainer, renderMain, renderSidebar, renderEngineEvaluation, ...modelArgs }: AnalysisBoardCoreProps) => React.JSX.Element;
|
|
23
|
+
export declare const AnalysisBoardCore: ({ renderContainer, renderMain, renderSidebar, renderEngineEvaluation, keyboardNav, ...modelArgs }: AnalysisBoardCoreProps) => React.JSX.Element;
|
|
19
24
|
type AnalysisBoardCoreViewProps = {
|
|
20
25
|
model: AnalysisBoardModel;
|
|
26
|
+
keyboardNav: boolean;
|
|
21
27
|
renderContainer: AnalysisBoardCoreProps['renderContainer'];
|
|
22
28
|
renderMain: AnalysisBoardCoreProps['renderMain'];
|
|
23
29
|
renderSidebar: AnalysisBoardCoreProps['renderSidebar'];
|
|
24
30
|
renderEngineEvaluation: AnalysisBoardCoreProps['renderEngineEvaluation'];
|
|
25
31
|
};
|
|
26
32
|
/** Pure composition (no layout styles) for testing and reuse. */
|
|
27
|
-
export declare const AnalysisBoardCoreView: ({ model, renderContainer, renderMain, renderSidebar, renderEngineEvaluation, }: AnalysisBoardCoreViewProps) => React.ReactNode;
|
|
33
|
+
export declare const AnalysisBoardCoreView: ({ model, keyboardNav, renderContainer, renderMain, renderSidebar, renderEngineEvaluation, }: AnalysisBoardCoreViewProps) => React.ReactNode;
|
|
28
34
|
export type { AnalysisBoardModel, UseAnalysisBoardModelArgs };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* HTML5 for mouse (desktop + Chrome device emulation), touch backend for real
|
|
4
|
+
* mobile devices. react-chessboard alone picks TouchBackend whenever
|
|
5
|
+
* `ontouchstart` is in window, which breaks mouse drags in DevTools emulation.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ChessboardDnDProvider: ({ children, }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const BOARD_THEME_IDS: readonly ["classic", "forest", "marine", "marble", "ivory", "ocean", "copper", "bubblegum", "sunset"];
|
|
2
|
+
export type BoardThemeId = (typeof BOARD_THEME_IDS)[number];
|
|
3
|
+
export type BoardThemeDefinition = {
|
|
4
|
+
label: string;
|
|
5
|
+
darkSquare: string;
|
|
6
|
+
lightSquare: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const DEFAULT_BOARD_THEME: BoardThemeId;
|
|
9
|
+
export declare const BOARD_THEMES: Record<BoardThemeId, BoardThemeDefinition>;
|
|
10
|
+
export declare function isBoardThemeId(value: unknown): value is BoardThemeId;
|
|
11
|
+
export declare function boardThemeFromLegacyUiTheme(_theme: 'light' | 'dark'): BoardThemeId;
|
|
12
|
+
export declare function getBoardThemeStyles(boardTheme: BoardThemeId): {
|
|
13
|
+
customDarkSquareStyle: {
|
|
14
|
+
backgroundColor: string;
|
|
15
|
+
};
|
|
16
|
+
customLightSquareStyle: {
|
|
17
|
+
backgroundColor: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { type BoardThemeId } from './boardThemes';
|
|
2
3
|
interface ChessboardThemeContextType {
|
|
3
4
|
customDarkSquareStyle: {
|
|
4
5
|
backgroundColor: string;
|
|
@@ -11,6 +12,7 @@ export declare const ChessboardThemeContext: import("react").Context<ChessboardT
|
|
|
11
12
|
export declare const useChessboardTheme: () => ChessboardThemeContextType;
|
|
12
13
|
/** @deprecated Use {@link useChessboardTheme}. */
|
|
13
14
|
export declare const useTheme: () => ChessboardThemeContextType;
|
|
15
|
+
/** @deprecated Use {@link getBoardThemeStyles}. */
|
|
14
16
|
export declare const getStylesForTheme: (theme: "light" | "dark") => {
|
|
15
17
|
customDarkSquareStyle: {
|
|
16
18
|
backgroundColor: string;
|
|
@@ -21,7 +23,9 @@ export declare const getStylesForTheme: (theme: "light" | "dark") => {
|
|
|
21
23
|
};
|
|
22
24
|
export type ThemeProviderProps = {
|
|
23
25
|
children?: ReactNode;
|
|
24
|
-
|
|
26
|
+
/** UI chrome palette; used when `boardTheme` is omitted. */
|
|
27
|
+
theme?: 'light' | 'dark';
|
|
28
|
+
boardTheme?: BoardThemeId;
|
|
25
29
|
};
|
|
26
|
-
export declare const ThemeProvider: ({ children, theme }: ThemeProviderProps) => import("react").JSX.Element;
|
|
30
|
+
export declare const ThemeProvider: ({ children, theme, boardTheme, }: ThemeProviderProps) => import("react").JSX.Element;
|
|
27
31
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AnalysisEngineOptions, EngineEvaluation } from './types';
|
|
3
|
+
export type SubscriberOptions = {
|
|
4
|
+
fen: string;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
depth: number;
|
|
7
|
+
multiPv: number;
|
|
8
|
+
priority: number;
|
|
9
|
+
};
|
|
10
|
+
type AnalysisEngineContextValue = {
|
|
11
|
+
register: (options: SubscriberOptions, listener: (evaluation: EngineEvaluation) => void) => number;
|
|
12
|
+
update: (id: number, options: SubscriberOptions) => void;
|
|
13
|
+
unregister: (id: number) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const useAnalysisEngineContext: () => AnalysisEngineContextValue | null;
|
|
16
|
+
export declare const normalizeSubscriberOptions: (fen: string, options?: AnalysisEngineOptions) => SubscriberOptions;
|
|
17
|
+
export type AnalysisEngineProviderProps = {
|
|
18
|
+
scriptUrl?: string;
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
};
|
|
21
|
+
export declare const AnalysisEngineProvider: ({ scriptUrl, children, }: AnalysisEngineProviderProps) => React.JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -23,5 +23,15 @@ export type AnalysisEngineOptions = {
|
|
|
23
23
|
multiPv?: number;
|
|
24
24
|
/** URL to stockfish-18-lite-single.js (host must serve .wasm alongside it). */
|
|
25
25
|
scriptUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Higher priority wins when multiple hooks share an {@link AnalysisEngineProvider}.
|
|
28
|
+
* Default 0.
|
|
29
|
+
*/
|
|
30
|
+
priority?: number;
|
|
31
|
+
/**
|
|
32
|
+
* When false, uses a dedicated worker even inside AnalysisEngineProvider
|
|
33
|
+
* (e.g. refutation comparing two positions at once).
|
|
34
|
+
*/
|
|
35
|
+
shared?: boolean;
|
|
26
36
|
};
|
|
27
37
|
export declare const DEFAULT_STOCKFISH_SCRIPT_URL = "/stockfish/stockfish-18-lite-single.js";
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { AnalysisEngineProvider } from './AnalysisEngineContext';
|
|
1
2
|
import { AnalysisEngineOptions, EngineEvaluation } from './types';
|
|
2
3
|
export declare const useAnalysisEngine: (fen: string, options?: AnalysisEngineOptions) => EngineEvaluation;
|
|
4
|
+
export { AnalysisEngineProvider };
|
|
@@ -3,4 +3,4 @@ import type { PlyNavigationProps } from './types';
|
|
|
3
3
|
* Step through a fixed move list. Omit {@link PlyNavigationProps.renderPlyNavigation}
|
|
4
4
|
* for the default inline-styled UI, or pass a custom renderer (e.g. MUI controls).
|
|
5
5
|
*/
|
|
6
|
-
export declare const PlyNavigation: ({ plyIndex, totalPly, canPrev, canNext, onGoFirst, onGoPrev, onGoNext, onGoLast, onGoTo, theme, showScrubber, showPlyLabel, renderPlyNavigation, }: PlyNavigationProps) => import("react").ReactNode;
|
|
6
|
+
export declare const PlyNavigation: ({ plyIndex, totalPly, canPrev, canNext, onGoFirst, onGoPrev, onGoNext, onGoLast, onGoTo, theme, keyboardNav, showScrubber, showPlyLabel, renderPlyNavigation, }: PlyNavigationProps) => import("react").ReactNode;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { PlyNavigation } from './PlyNavigation';
|
|
2
2
|
export { DefaultPlyNavigation, defaultRenderPlyNavigation, } from './DefaultPlyNavigation';
|
|
3
|
+
export { isEditableKeyboardTarget, type PositionKeyboardNavOptions, } from './positionKeyboardNav';
|
|
4
|
+
export { usePositionKeyboardNav } from './usePositionKeyboardNav';
|
|
3
5
|
export { navRowStyle, navButtonStyle, scrubberInputStyle, plyLabelStyle, palette as plyNavigationPalette, } from './plyNavigationStyles';
|
|
4
6
|
export type { PlyNavigationModel, PlyNavigationProps, PlyNavigationRenderProps, PlyNavigationTheme, } from './types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** True when the event target is a field where arrow keys should type, not navigate. */
|
|
2
|
+
export declare function isEditableKeyboardTarget(target: EventTarget | null): boolean;
|
|
3
|
+
export type PositionKeyboardNavOptions = {
|
|
4
|
+
/** When false, keyboard shortcuts are not registered. Default true. */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
canPrev: boolean;
|
|
7
|
+
canNext: boolean;
|
|
8
|
+
onPrev: () => void;
|
|
9
|
+
onNext: () => void;
|
|
10
|
+
onFirst?: () => void;
|
|
11
|
+
onLast?: () => void;
|
|
12
|
+
};
|
|
@@ -24,6 +24,11 @@ export type PlyNavigationRenderProps = PlyNavigationModel & {
|
|
|
24
24
|
};
|
|
25
25
|
export type PlyNavigationProps = PlyNavigationModel & {
|
|
26
26
|
theme?: PlyNavigationTheme;
|
|
27
|
+
/**
|
|
28
|
+
* Register ArrowLeft/ArrowRight/Home/End shortcuts while this nav is mounted.
|
|
29
|
+
* Default true.
|
|
30
|
+
*/
|
|
31
|
+
keyboardNav?: boolean;
|
|
27
32
|
/** Range scrubber between prev/next. Default true. */
|
|
28
33
|
showScrubber?: boolean;
|
|
29
34
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PositionKeyboardNavOptions } from './positionKeyboardNav';
|
|
2
|
+
/**
|
|
3
|
+
* Global keyboard shortcuts for browsing positions:
|
|
4
|
+
* - ArrowLeft: previous
|
|
5
|
+
* - ArrowRight: next
|
|
6
|
+
* - Home: first (when {@link PositionKeyboardNavOptions.onFirst} is provided)
|
|
7
|
+
* - End: last (when {@link PositionKeyboardNavOptions.onLast} is provided)
|
|
8
|
+
*
|
|
9
|
+
* Ignores keypresses while focus is in an input, textarea, select, or
|
|
10
|
+
* contenteditable element, and ignores modified keys (Alt/Ctrl/Meta).
|
|
11
|
+
*/
|
|
12
|
+
export declare function usePositionKeyboardNav({ enabled, canPrev, canNext, onPrev, onNext, onFirst, onLast, }: PositionKeyboardNavOptions): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ExpectedMoveDropResult = {
|
|
2
|
+
kind: 'ignored';
|
|
3
|
+
} | {
|
|
4
|
+
kind: 'illegal';
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'correct';
|
|
7
|
+
uci: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'incorrect';
|
|
10
|
+
uci: string;
|
|
11
|
+
};
|
|
12
|
+
export type CreateExpectedMoveDropHandlerOptions = {
|
|
13
|
+
fen: string;
|
|
14
|
+
expectedUci: string | null | undefined;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
onCorrect: (uci: string) => void;
|
|
17
|
+
onIncorrect: (uci: string) => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Evaluate a training drop without mutating board position.
|
|
21
|
+
* Returns `false` for incorrect attempts so react-chessboard snaps the piece back.
|
|
22
|
+
*/
|
|
23
|
+
export declare function evaluateExpectedMoveDrop(fen: string, sourceSquare: string, targetSquare: string, piece: string, expectedUci: string | null | undefined, enabled: boolean): ExpectedMoveDropResult;
|
|
24
|
+
export declare function createExpectedMoveDropHandler({ fen, expectedUci, enabled, onCorrect, onIncorrect, }: CreateExpectedMoveDropHandlerOptions): (sourceSquare: string, targetSquare: string, piece: string) => boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { REFUTATION_EVAL_GAP_CP, REFUTATION_EVAL_GAP_PAWNS, fenAfterUci, lineEvalCpForGap, refutationEngineOptions, refutationEvalGapCp, refutationFromEvaluation, type RefutationResult, } from './refutation';
|
|
2
|
+
export { MISS_MOVE_ANIMATION_MS, MISS_REFUTATION_MAX_WAIT_MS, MISS_REFUTATION_PAUSE_MS, MISS_WRONG_PAUSE_MS, getMissDisplay, type MissDisplay, type MissSequencePhase, type MissSequenceState, } from './missDisplay';
|
|
3
|
+
export { useMissRefutation } from './useMissRefutation';
|
|
4
|
+
export { useMissSequence } from './useMissSequence';
|
|
5
|
+
export { useMissBoard } from './useMissBoard';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type MissSequencePhase = 'wrong' | 'refutation' | 'answer' | 'retry';
|
|
2
|
+
export type MissSequenceState = {
|
|
3
|
+
setupFen: string;
|
|
4
|
+
attemptedUci: string;
|
|
5
|
+
phase: MissSequencePhase;
|
|
6
|
+
};
|
|
7
|
+
export type MissDisplay = {
|
|
8
|
+
fen: string | null;
|
|
9
|
+
arrows: [string, string, string][];
|
|
10
|
+
animating: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const MISS_WRONG_PAUSE_MS = 450;
|
|
13
|
+
export declare const MISS_REFUTATION_PAUSE_MS = 900;
|
|
14
|
+
export declare const MISS_REFUTATION_MAX_WAIT_MS = 4000;
|
|
15
|
+
export declare const MISS_MOVE_ANIMATION_MS = 220;
|
|
16
|
+
export declare function getMissDisplay(sequence: MissSequenceState | null, expectedUci: string | null, refutationUci: string | null, answerArrowColor: string): MissDisplay;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AnalysisEngineOptions, EngineEvaluation, EngineLine } from '../../engine/types';
|
|
2
|
+
/** Minimum eval loss (pawns) from the wrong move before showing a refutation. */
|
|
3
|
+
export declare const REFUTATION_EVAL_GAP_PAWNS = 0.5;
|
|
4
|
+
export declare const REFUTATION_EVAL_GAP_CP: number;
|
|
5
|
+
export type RefutationResult = {
|
|
6
|
+
fenAfterWrong: string | null;
|
|
7
|
+
refutationUci: string | null;
|
|
8
|
+
refutationSan: string | null;
|
|
9
|
+
refutationLine: string | null;
|
|
10
|
+
loading: boolean;
|
|
11
|
+
error: string | null;
|
|
12
|
+
};
|
|
13
|
+
export declare const refutationEngineOptions: AnalysisEngineOptions;
|
|
14
|
+
export declare function fenAfterUci(fen: string, uci: string): string | null;
|
|
15
|
+
/** Centipawn score from side to move, comparable across sibling positions. */
|
|
16
|
+
export declare function lineEvalCpForGap(line: EngineLine | undefined): number | null;
|
|
17
|
+
/** How much better the opponent's eval is after the wrong move vs the correct one. */
|
|
18
|
+
export declare function refutationEvalGapCp(evalAfterWrong: EngineEvaluation, evalAfterCorrect: EngineEvaluation): number | null;
|
|
19
|
+
export declare function refutationFromEvaluation(fenAfterWrong: string, evaluation: EngineEvaluation, evalGapCp: number | null, evalGapApplies: boolean, evalGapLoading: boolean): Omit<RefutationResult, 'fenAfterWrong'>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AnalysisEngineOptions } from '../../engine/types';
|
|
2
|
+
type MissFeedback = 'correct' | 'incorrect' | null;
|
|
3
|
+
export declare function useMissBoard({ feedback, expectedUci, positionFen, answerArrowColor, autoShowWrongMoves, engineOptions, }: {
|
|
4
|
+
feedback: MissFeedback;
|
|
5
|
+
expectedUci: string | null;
|
|
6
|
+
positionFen: string;
|
|
7
|
+
answerArrowColor: string;
|
|
8
|
+
autoShowWrongMoves?: boolean;
|
|
9
|
+
engineOptions?: AnalysisEngineOptions;
|
|
10
|
+
}): {
|
|
11
|
+
missSequence: {
|
|
12
|
+
sequence: import("./missDisplay").MissSequenceState | null;
|
|
13
|
+
refutation: import("./refutation").RefutationResult;
|
|
14
|
+
display: import("./missDisplay").MissDisplay;
|
|
15
|
+
startSequence: (setupFen: string, attemptedUci: string) => void;
|
|
16
|
+
clearSequence: () => void;
|
|
17
|
+
};
|
|
18
|
+
refutation: import("./refutation").RefutationResult;
|
|
19
|
+
customArrows: [string, string, string][];
|
|
20
|
+
boardPosition: string;
|
|
21
|
+
boardAnimating: boolean;
|
|
22
|
+
wrapDropHandler: (onDrop: (source: string, target: string, piece: string) => boolean, { enabled, dropFen, expectedMoveUci, }: {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
dropFen?: string;
|
|
25
|
+
expectedMoveUci?: string | null;
|
|
26
|
+
}) => (source: string, target: string, piece: string) => boolean;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AnalysisEngineOptions } from '../../engine/types';
|
|
2
|
+
import { type RefutationResult } from './refutation';
|
|
3
|
+
export declare function useMissRefutation(setupFen: string | null, attemptedUci: string | null, expectedUci: string | null, enabled: boolean, engineOptions: AnalysisEngineOptions): RefutationResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnalysisEngineOptions } from '../../engine/types';
|
|
2
|
+
import { type MissDisplay, type MissSequencePhase, type MissSequenceState } from './missDisplay';
|
|
3
|
+
export type { MissSequencePhase, MissDisplay };
|
|
4
|
+
export declare function useMissSequence(feedback: 'correct' | 'incorrect' | null, expectedUci: string | null, engineOptions: AnalysisEngineOptions, answerArrowColor: string, autoShowWrongMoves: boolean): {
|
|
5
|
+
sequence: MissSequenceState | null;
|
|
6
|
+
refutation: import("./refutation").RefutationResult;
|
|
7
|
+
display: MissDisplay;
|
|
8
|
+
startSequence: (setupFen: string, attemptedUci: string) => void;
|
|
9
|
+
clearSequence: () => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Resolve a board drag into a legal UCI string, or null when illegal. */
|
|
2
|
+
export declare function uciFromDrop(fen: string, sourceSquare: string, targetSquare: string, piece: string): string | null;
|
|
3
|
+
export declare function matchesExpectedUci(uci: string, expectedUci: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bump the revision counter to force a controlled chessboard re-render after a
|
|
3
|
+
* rejected drop. Pair with returning `false` from `onPieceDrop` so the board
|
|
4
|
+
* snaps back without changing the controlled `position` FEN.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useBoardRevision(): {
|
|
7
|
+
revision: number;
|
|
8
|
+
bumpRevision: () => void;
|
|
9
|
+
};
|
package/dist/index.d.ts
CHANGED