react-chess-explorer 0.0.1
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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/features/explorer/ExplorerPlaceholder.d.ts +10 -0
- package/dist/features/explorer/GameReplayTrainer.d.ts +21 -0
- package/dist/features/explorer/PositionReferenceExplorer.d.ts +4 -0
- package/dist/features/explorer/components/DefaultBoardNav.d.ts +8 -0
- package/dist/features/explorer/components/EloRangeFilter.d.ts +9 -0
- package/dist/features/explorer/components/ExplorerStatusBanner.d.ts +5 -0
- package/dist/features/explorer/components/GamesTable.d.ts +6 -0
- package/dist/features/explorer/components/LineHeader.d.ts +4 -0
- package/dist/features/explorer/components/MoveStatsTable.d.ts +7 -0
- package/dist/features/explorer/components/PositionGamesPanel.d.ts +15 -0
- package/dist/features/explorer/components/explorerStyles.d.ts +26 -0
- package/dist/features/explorer/constants.d.ts +4 -0
- package/dist/features/explorer/core/PositionReferenceExplorerCore.d.ts +2 -0
- package/dist/features/explorer/core/renderProps.d.ts +77 -0
- package/dist/features/explorer/defaults/DefaultReferenceLayout.d.ts +3 -0
- package/dist/features/explorer/defaults/DefaultReferencePanel.d.ts +10 -0
- package/dist/features/explorer/defaults/DefaultVariationsStrip.d.ts +3 -0
- package/dist/features/explorer/defaults/defaultRenderers.d.ts +8 -0
- package/dist/features/explorer/defaults/index.d.ts +7 -0
- package/dist/features/explorer/gameReplayUtils.d.ts +6 -0
- package/dist/features/explorer/hooks/useGameReplayTraining.d.ts +22 -0
- package/dist/features/explorer/hooks/usePositionHistory.d.ts +19 -0
- package/dist/features/explorer/hooks/usePositionReferenceData.d.ts +41 -0
- package/dist/features/explorer/hooks/useVariationLines.d.ts +16 -0
- package/dist/features/explorer/index.d.ts +15 -0
- package/dist/features/explorer/mocks.d.ts +4 -0
- package/dist/features/explorer/positionUtils.d.ts +21 -0
- package/dist/features/explorer/referenceLayout.d.ts +13 -0
- package/dist/features/explorer/types.d.ts +96 -0
- package/dist/features/explorer/variationLines.d.ts +5 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +1105 -0
- package/dist/index.js +1133 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Robert Blackwell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# react-chess-explorer
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
npm install
|
|
5
|
+
npm run build
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
React components for **browsing and replaying chess games**. This package depends on **`react-chess-core` only** (board + engine primitives), not `react-chess-puzzle-kit`.
|
|
9
|
+
|
|
10
|
+
**Status:** Phase 5 scaffold — paste requirements into `docs/REQUIREMENTS.md` (or issue) before implementing replay UI.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Local setup
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Build core first
|
|
18
|
+
cd ../react-chess-core && npm run build
|
|
19
|
+
|
|
20
|
+
cd ../react-chess-explorer
|
|
21
|
+
npm install
|
|
22
|
+
npm run build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Peer dependencies:** `react`, `react-chessboard`, `chess.js`, **`react-chess-core`**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install react-chess-explorer react-chess-core
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Exports (scaffold)
|
|
34
|
+
|
|
35
|
+
| Export | Role |
|
|
36
|
+
|--------|------|
|
|
37
|
+
| **`ExplorerPlaceholder`** | Themed board at start position + scaffold label |
|
|
38
|
+
| **`EXPLORER_START_FEN`** | Default FEN constant |
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
Add product/API requirements here when ready:
|
|
45
|
+
|
|
46
|
+
- `docs/REQUIREMENTS.md` (create when you paste the doc)
|
|
47
|
+
|
|
48
|
+
Planned scope (from migration plan): move list, ply navigation, optional engine — wired to EndChess `/games` routes.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Related packages
|
|
53
|
+
|
|
54
|
+
| Package | Role |
|
|
55
|
+
|---------|------|
|
|
56
|
+
| [react-chess-core](https://github.com/reblackwell3/react-chess-core) | Board theme, highlights, Stockfish |
|
|
57
|
+
| [react-chess-puzzle-kit](https://github.com/reblackwell3/react-chess-puzzle-kit) | Puzzles (separate; not a dependency) |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT © Robert Blackwell
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ExplorerPlaceholderProps = {
|
|
2
|
+
theme?: "light" | "dark";
|
|
3
|
+
/** Pixel width of the board. */
|
|
4
|
+
boardWidth?: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Scaffold UI — proves core wiring and Rollup build.
|
|
8
|
+
* Replace with game replay once requirements are defined.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ExplorerPlaceholder: ({ theme, boardWidth, }: ExplorerPlaceholderProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ExplorerGameReplayApiDto } from "./types";
|
|
3
|
+
export type GameReplayTrainerProps = {
|
|
4
|
+
gameId: string;
|
|
5
|
+
startFen: string;
|
|
6
|
+
fetchGame: (gameId: string) => Promise<ExplorerGameReplayApiDto | null>;
|
|
7
|
+
onExit?: () => void;
|
|
8
|
+
theme?: "light" | "dark";
|
|
9
|
+
boardWidth?: number;
|
|
10
|
+
renderStatus?: (props: {
|
|
11
|
+
loading: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
complete: boolean;
|
|
14
|
+
feedback: "correct" | "incorrect" | null;
|
|
15
|
+
lastExpectedSan: string | null;
|
|
16
|
+
plyIndex: number;
|
|
17
|
+
totalPlies: number;
|
|
18
|
+
game: ExplorerGameReplayApiDto | null;
|
|
19
|
+
}) => ReactNode;
|
|
20
|
+
};
|
|
21
|
+
export declare const GameReplayTrainer: ({ gameId, startFen, fetchGame, onExit, theme, boardWidth, renderStatus, }: GameReplayTrainerProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PositionReferenceExplorerCoreProps } from "./core/renderProps";
|
|
2
|
+
export type PositionReferenceExplorerProps = PositionReferenceExplorerCoreProps;
|
|
3
|
+
/** Reference explorer with library default layout and renderers (ChessBase-style grid). */
|
|
4
|
+
export declare const PositionReferenceExplorer: (props: PositionReferenceExplorerProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type BoardNavRenderProps = {
|
|
2
|
+
canGoBack: boolean;
|
|
3
|
+
canGoForward: boolean;
|
|
4
|
+
onBack: () => void;
|
|
5
|
+
onForward: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const DefaultBoardNav: ({ canGoBack, canGoForward, onBack, onForward, }: BoardNavRenderProps) => import("react").JSX.Element;
|
|
8
|
+
export declare const defaultRenderBoardNav: (props: BoardNavRenderProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type EloRangeFilterProps = {
|
|
2
|
+
minElo: number;
|
|
3
|
+
maxElo: number;
|
|
4
|
+
defaultMinElo: number;
|
|
5
|
+
defaultMaxElo: number;
|
|
6
|
+
onMinEloChange: (value: number) => void;
|
|
7
|
+
onMaxEloChange: (value: number) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const EloRangeFilter: ({ minElo, maxElo, defaultMinElo, defaultMaxElo, onMinEloChange, onMaxEloChange, }: EloRangeFilterProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PositionGameRowApiDto } from "../types";
|
|
2
|
+
export type GamesTableProps = {
|
|
3
|
+
games: PositionGameRowApiDto[];
|
|
4
|
+
onGameSelect?: (game: PositionGameRowApiDto) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const GamesTable: ({ games, onGameSelect }: GamesTableProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PositionMoveApiDto } from "../types";
|
|
2
|
+
export type MoveStatsTableProps = {
|
|
3
|
+
moves: PositionMoveApiDto[];
|
|
4
|
+
selectedUci?: string;
|
|
5
|
+
onMoveSelect: (move: PositionMoveApiDto) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const MoveStatsTable: ({ moves, selectedUci, onMoveSelect, }: MoveStatsTableProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PositionGameRowApiDto } from "../types";
|
|
2
|
+
export type PositionGamesPanelProps = {
|
|
3
|
+
games: PositionGameRowApiDto[];
|
|
4
|
+
lineLabel: string;
|
|
5
|
+
minElo: number;
|
|
6
|
+
maxElo: number;
|
|
7
|
+
defaultMinElo: number;
|
|
8
|
+
defaultMaxElo: number;
|
|
9
|
+
topOnly: boolean;
|
|
10
|
+
onMinEloChange: (value: number) => void;
|
|
11
|
+
onMaxEloChange: (value: number) => void;
|
|
12
|
+
onTopOnlyChange: (value: boolean) => void;
|
|
13
|
+
onGameSelect?: (game: PositionGameRowApiDto) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const PositionGamesPanel: ({ games, lineLabel, minElo, maxElo, defaultMinElo, defaultMaxElo, topOnly, onMinEloChange, onMaxEloChange, onTopOnlyChange, onGameSelect, }: PositionGamesPanelProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
export declare const panelStyle: CSSProperties;
|
|
3
|
+
export declare const tableStyle: CSSProperties;
|
|
4
|
+
export declare const thStyle: CSSProperties;
|
|
5
|
+
export declare const tdStyle: CSSProperties;
|
|
6
|
+
export declare const sectionTitleStyle: CSSProperties;
|
|
7
|
+
/** Full-width shell: board | reference — no wrap, no footer below. */
|
|
8
|
+
export declare const referenceShellStyle: CSSProperties;
|
|
9
|
+
export declare const boardColumnStyle: CSSProperties;
|
|
10
|
+
export declare const boardNavStyle: CSSProperties;
|
|
11
|
+
export declare const boardNavButtonStyle: CSSProperties;
|
|
12
|
+
export declare const referencePanelStyle: CSSProperties;
|
|
13
|
+
export declare const referenceTabBarStyle: CSSProperties;
|
|
14
|
+
export declare const referenceTabLabelStyle: CSSProperties;
|
|
15
|
+
export declare const moveStatsSectionStyle: CSSProperties;
|
|
16
|
+
export declare const variationsStripStyle: CSSProperties;
|
|
17
|
+
export declare const variationsTabStyle: CSSProperties;
|
|
18
|
+
export declare const gamesSectionStyle: CSSProperties;
|
|
19
|
+
export declare const gamesHeaderStyle: CSSProperties;
|
|
20
|
+
export declare const gamesScrollStyle: CSSProperties;
|
|
21
|
+
export declare const gamesToolbarStyle: CSSProperties;
|
|
22
|
+
export declare const statusInlineStyle: CSSProperties;
|
|
23
|
+
/** @deprecated Use referenceShellStyle — kept for ExplorerPlaceholder */
|
|
24
|
+
export declare const layoutStyle: CSSProperties;
|
|
25
|
+
/** @deprecated Use referencePanelStyle */
|
|
26
|
+
export declare const sidebarStyle: CSSProperties;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Standard start position — placeholder until game replay is implemented. */
|
|
2
|
+
export declare const EXPLORER_START_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
|
3
|
+
/** Delay between plies when animating a clicked variation line. */
|
|
4
|
+
export declare const VARIATION_LINE_STEP_MS = 500;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { PositionReferenceExplorerCoreProps } from "./renderProps";
|
|
2
|
+
export declare const PositionReferenceExplorerCore: ({ fen: fenProp, onFenChange, initialLineSans, onLineSansChange, fetchPosition, fetchPositionGames, fetchPositionVariations, theme, boardWidth, defaultMinElo, defaultMaxElo, fillHeight, layoutMinHeight, renderLayout, renderStatus, renderMoveStats, renderVariationsStrip, renderGamesPanel, renderBoardNav, onGameSelect, }: PositionReferenceExplorerCoreProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { FetchPositionGamesParams, FetchPositionVariationsParams, PositionApiDto, PositionGameRowApiDto, PositionGamesApiDto, PositionMoveApiDto, PositionVariationLineApiDto, PositionVariationsApiDto } from "../types";
|
|
3
|
+
import type { VariationsTab } from "../variationLines";
|
|
4
|
+
export type ReferenceLayoutRenderProps = {
|
|
5
|
+
theme: "light" | "dark";
|
|
6
|
+
board: ReactNode;
|
|
7
|
+
referencePanel: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export type BoardNavRenderProps = {
|
|
10
|
+
canGoBack: boolean;
|
|
11
|
+
canGoForward: boolean;
|
|
12
|
+
onBack: () => void;
|
|
13
|
+
onForward: () => void;
|
|
14
|
+
};
|
|
15
|
+
export type ExplorerStatusRenderProps = {
|
|
16
|
+
error: string | null;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type MoveStatsRenderProps = {
|
|
20
|
+
moves: PositionMoveApiDto[];
|
|
21
|
+
selectedUci?: string;
|
|
22
|
+
onMoveSelect: (move: PositionMoveApiDto) => void;
|
|
23
|
+
};
|
|
24
|
+
export type LineHeaderRenderProps = {
|
|
25
|
+
label: string;
|
|
26
|
+
gameCount: number;
|
|
27
|
+
};
|
|
28
|
+
export type GamesPanelRenderProps = {
|
|
29
|
+
games: PositionGameRowApiDto[];
|
|
30
|
+
lineLabel: string;
|
|
31
|
+
minElo: number;
|
|
32
|
+
maxElo: number;
|
|
33
|
+
defaultMinElo: number;
|
|
34
|
+
defaultMaxElo: number;
|
|
35
|
+
topOnly: boolean;
|
|
36
|
+
onMinEloChange: (value: number) => void;
|
|
37
|
+
onMaxEloChange: (value: number) => void;
|
|
38
|
+
onTopOnlyChange: (value: boolean) => void;
|
|
39
|
+
/** Start replay training for a database game from the current board FEN. */
|
|
40
|
+
onGameSelect?: (game: PositionGameRowApiDto) => void;
|
|
41
|
+
};
|
|
42
|
+
export type VariationsStripRenderProps = {
|
|
43
|
+
theme: "light" | "dark";
|
|
44
|
+
tab: VariationsTab;
|
|
45
|
+
onTabChange: (tab: VariationsTab) => void;
|
|
46
|
+
lines: PositionVariationLineApiDto[];
|
|
47
|
+
loading: boolean;
|
|
48
|
+
selectedLineKey?: string;
|
|
49
|
+
forwardSans: string[];
|
|
50
|
+
onLineSelect: (line: PositionVariationLineApiDto) => void;
|
|
51
|
+
};
|
|
52
|
+
export type PositionReferenceExplorerCoreProps = {
|
|
53
|
+
fen?: string;
|
|
54
|
+
onFenChange?: (fen: string) => void;
|
|
55
|
+
/** Seed move history on mount (e.g. from URL). Applied from {@link EXPLORER_START_FEN}. */
|
|
56
|
+
initialLineSans?: string[];
|
|
57
|
+
/** Fired after mount when the played SAN line changes (back/forward/new move). */
|
|
58
|
+
onLineSansChange?: (lineSans: string[]) => void;
|
|
59
|
+
fetchPosition: (fen: string) => Promise<PositionApiDto | null>;
|
|
60
|
+
fetchPositionGames: (params: FetchPositionGamesParams) => Promise<PositionGamesApiDto>;
|
|
61
|
+
fetchPositionVariations: (params: FetchPositionVariationsParams) => Promise<PositionVariationsApiDto | null>;
|
|
62
|
+
theme?: "light" | "dark";
|
|
63
|
+
boardWidth?: number;
|
|
64
|
+
defaultMinElo?: number;
|
|
65
|
+
defaultMaxElo?: number;
|
|
66
|
+
/** When true, shell uses full viewport height (no extra content below the grid). */
|
|
67
|
+
fillHeight?: boolean;
|
|
68
|
+
layoutMinHeight?: string;
|
|
69
|
+
renderLayout?: (props: ReferenceLayoutRenderProps) => ReactNode;
|
|
70
|
+
renderStatus?: (props: ExplorerStatusRenderProps) => ReactNode;
|
|
71
|
+
renderMoveStats?: (props: MoveStatsRenderProps) => ReactNode;
|
|
72
|
+
renderVariationsStrip?: (props: VariationsStripRenderProps) => ReactNode;
|
|
73
|
+
renderGamesPanel?: (props: GamesPanelRenderProps) => ReactNode;
|
|
74
|
+
renderBoardNav?: (props: BoardNavRenderProps) => ReactNode;
|
|
75
|
+
/** When set, games panel can launch per-game replay training. */
|
|
76
|
+
onGameSelect?: (game: PositionGameRowApiDto) => void;
|
|
77
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ReferenceLayoutRenderProps } from "../core/renderProps";
|
|
2
|
+
export declare const DefaultReferenceLayout: ({ board, referencePanel, }: ReferenceLayoutRenderProps) => import("react").JSX.Element;
|
|
3
|
+
export declare const defaultRenderLayout: (props: ReferenceLayoutRenderProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DefaultReferencePanelProps = {
|
|
3
|
+
theme: "light" | "dark";
|
|
4
|
+
status: ReactNode;
|
|
5
|
+
moveStats: ReactNode;
|
|
6
|
+
variationsStrip: ReactNode;
|
|
7
|
+
gamesPanel: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/** Right column shell: tab bar + stacked sections (no page footer below). */
|
|
10
|
+
export declare const DefaultReferencePanel: ({ theme, status, moveStats, variationsStrip, gamesPanel, }: DefaultReferencePanelProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { VariationsStripRenderProps } from "../core/renderProps";
|
|
2
|
+
export declare const DefaultVariationsStrip: ({ theme, tab, onTabChange, lines, loading, selectedLineKey, forwardSans, onLineSelect, }: VariationsStripRenderProps) => import("react").JSX.Element;
|
|
3
|
+
export declare const defaultRenderVariationsStrip: (props: VariationsStripRenderProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defaultRenderBoardNav } from "../components/DefaultBoardNav";
|
|
2
|
+
import type { ExplorerStatusRenderProps, GamesPanelRenderProps, MoveStatsRenderProps } from "../core/renderProps";
|
|
3
|
+
import { defaultRenderLayout } from "./DefaultReferenceLayout";
|
|
4
|
+
import { defaultRenderVariationsStrip } from "./DefaultVariationsStrip";
|
|
5
|
+
export { defaultRenderLayout, defaultRenderVariationsStrip, defaultRenderBoardNav, };
|
|
6
|
+
export declare const defaultRenderStatus: (props: ExplorerStatusRenderProps) => import("react").JSX.Element;
|
|
7
|
+
export declare const defaultRenderMoveStats: (props: MoveStatsRenderProps) => import("react").JSX.Element;
|
|
8
|
+
export declare const defaultRenderGamesPanel: (props: GamesPanelRenderProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DEFAULT_REFERENCE_LAYOUT } from "../referenceLayout";
|
|
2
|
+
export type { ReferenceLayoutConfig } from "../referenceLayout";
|
|
3
|
+
export { DefaultReferenceLayout, defaultRenderLayout, } from "./DefaultReferenceLayout";
|
|
4
|
+
export { DefaultReferencePanel } from "./DefaultReferencePanel";
|
|
5
|
+
export { DefaultVariationsStrip, defaultRenderVariationsStrip, } from "./DefaultVariationsStrip";
|
|
6
|
+
export { defaultRenderBoardNav, defaultRenderGamesPanel, defaultRenderMoveStats, defaultRenderStatus, } from "./defaultRenderers";
|
|
7
|
+
export { DefaultBoardNav } from "../components/DefaultBoardNav";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Chess } from "chess.js";
|
|
2
|
+
export declare function fenAtPly(movesUci: string[], ply: number): string;
|
|
3
|
+
/** Index of the next move to play to reach `targetFen`, or 0 if not found. */
|
|
4
|
+
export declare function findPlyIndexForFen(movesUci: string[], targetFen: string): number;
|
|
5
|
+
export declare function applyUci(chess: Chess, uci: string): void;
|
|
6
|
+
export declare function uciFromDrop(fen: string, sourceSquare: string, targetSquare: string, piece: string): string | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExplorerGameReplayApiDto } from "../types";
|
|
2
|
+
export type GameReplayFeedback = "correct" | "incorrect" | null;
|
|
3
|
+
export type UseGameReplayTrainingOptions = {
|
|
4
|
+
gameId: string;
|
|
5
|
+
/** Board FEN when the user picked this game (explorer position). */
|
|
6
|
+
startFen: string;
|
|
7
|
+
fetchGame: (gameId: string) => Promise<ExplorerGameReplayApiDto | null>;
|
|
8
|
+
};
|
|
9
|
+
export declare function useGameReplayTraining({ gameId, startFen, fetchGame, }: UseGameReplayTrainingOptions): {
|
|
10
|
+
game: ExplorerGameReplayApiDto | null;
|
|
11
|
+
fen: string;
|
|
12
|
+
plyIndex: number;
|
|
13
|
+
totalPlies: number;
|
|
14
|
+
complete: boolean;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
error: string | null;
|
|
17
|
+
feedback: GameReplayFeedback;
|
|
18
|
+
lastExpectedSan: string | null;
|
|
19
|
+
expectedSan: string | undefined;
|
|
20
|
+
handlePieceDrop: (sourceSquare: string, targetSquare: string, piece: string) => boolean;
|
|
21
|
+
revealMove: () => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type PositionHistoryEntry = {
|
|
2
|
+
fen: string;
|
|
3
|
+
/** SAN of the move played from the previous entry to reach this FEN. */
|
|
4
|
+
lastSan?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function usePositionHistory(initialFen: string): {
|
|
7
|
+
canGoBack: boolean;
|
|
8
|
+
canGoForward: boolean;
|
|
9
|
+
lineSans: string[];
|
|
10
|
+
forwardSans: string[];
|
|
11
|
+
pushEntry: (fen: string, lastSan?: string) => PositionHistoryEntry;
|
|
12
|
+
pushEntries: (entries: {
|
|
13
|
+
fen: string;
|
|
14
|
+
lastSan: string;
|
|
15
|
+
}[]) => void;
|
|
16
|
+
goBack: () => PositionHistoryEntry | null;
|
|
17
|
+
goForward: () => PositionHistoryEntry | null;
|
|
18
|
+
resetHistory: (fen: string) => PositionHistoryEntry;
|
|
19
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FetchPositionGamesParams, PositionApiDto, PositionGamesApiDto, PositionMoveApiDto } from "../types";
|
|
2
|
+
import type { PositionVariationLineApiDto } from "../types";
|
|
3
|
+
import type { VariationsTab } from "../variationLines";
|
|
4
|
+
export type UsePositionReferenceDataOptions = {
|
|
5
|
+
fenProp?: string;
|
|
6
|
+
onFenChange?: (fen: string) => void;
|
|
7
|
+
initialLineSans?: string[];
|
|
8
|
+
onLineSansChange?: (lineSans: string[]) => void;
|
|
9
|
+
fetchPosition: (fen: string) => Promise<PositionApiDto | null>;
|
|
10
|
+
fetchPositionGames: (params: FetchPositionGamesParams) => Promise<PositionGamesApiDto>;
|
|
11
|
+
defaultMinElo: number;
|
|
12
|
+
defaultMaxElo: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function usePositionReferenceData({ fenProp, onFenChange, initialLineSans, onLineSansChange, fetchPosition, fetchPositionGames, defaultMinElo, defaultMaxElo, }: UsePositionReferenceDataOptions): {
|
|
15
|
+
fen: string;
|
|
16
|
+
boardFen: string;
|
|
17
|
+
position: PositionApiDto | null;
|
|
18
|
+
games: PositionGamesApiDto | null;
|
|
19
|
+
gamesMoveFilterUci: string | undefined;
|
|
20
|
+
minElo: number;
|
|
21
|
+
maxElo: number;
|
|
22
|
+
topOnly: boolean;
|
|
23
|
+
loading: boolean;
|
|
24
|
+
error: string | null;
|
|
25
|
+
lineLabel: string;
|
|
26
|
+
canGoBack: boolean;
|
|
27
|
+
canGoForward: boolean;
|
|
28
|
+
variationsTab: VariationsTab;
|
|
29
|
+
forwardSans: string[];
|
|
30
|
+
selectedVariationKey: string | undefined;
|
|
31
|
+
setMinElo: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
32
|
+
setMaxElo: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
33
|
+
setTopOnly: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
34
|
+
setVariationsTab: import("react").Dispatch<import("react").SetStateAction<VariationsTab>>;
|
|
35
|
+
setGamesMoveFilterUci: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
36
|
+
handleMoveSelect: (move: PositionMoveApiDto) => void;
|
|
37
|
+
handleLineSelect: (line: PositionVariationLineApiDto) => void;
|
|
38
|
+
handlePieceDrop: (sourceSquare: string, targetSquare: string, piece: string) => boolean;
|
|
39
|
+
handleBack: () => void;
|
|
40
|
+
handleForward: () => void;
|
|
41
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FetchPositionVariationsParams, PositionVariationLineApiDto, PositionVariationsApiDto } from "../types";
|
|
2
|
+
import type { VariationsTab } from "../variationLines";
|
|
3
|
+
export type UseVariationLinesOptions = {
|
|
4
|
+
fen: string;
|
|
5
|
+
tab: VariationsTab;
|
|
6
|
+
minElo: number;
|
|
7
|
+
maxElo: number;
|
|
8
|
+
fetchPositionVariations: (params: FetchPositionVariationsParams) => Promise<PositionVariationsApiDto | null>;
|
|
9
|
+
lineCount?: number;
|
|
10
|
+
lineDepth?: number;
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function useVariationLines({ fen, tab, minElo, maxElo, fetchPositionVariations, lineCount, lineDepth, enabled, }: UseVariationLinesOptions): {
|
|
14
|
+
lines: PositionVariationLineApiDto[];
|
|
15
|
+
loading: boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { EXPLORER_START_FEN } from "./constants";
|
|
2
|
+
export { ExplorerPlaceholder, type ExplorerPlaceholderProps, } from "./ExplorerPlaceholder";
|
|
3
|
+
export { PositionReferenceExplorer, type PositionReferenceExplorerProps, } from "./PositionReferenceExplorer";
|
|
4
|
+
export { PositionReferenceExplorerCore } from "./core/PositionReferenceExplorerCore";
|
|
5
|
+
export type { PositionReferenceExplorerCoreProps, ReferenceLayoutRenderProps, ExplorerStatusRenderProps, MoveStatsRenderProps, GamesPanelRenderProps, VariationsStripRenderProps, BoardNavRenderProps, } from "./core/renderProps";
|
|
6
|
+
export type { VariationsTab } from "./variationLines";
|
|
7
|
+
export { DEFAULT_REFERENCE_LAYOUT, DefaultReferenceLayout, DefaultReferencePanel, DefaultVariationsStrip, defaultRenderLayout, defaultRenderStatus, defaultRenderMoveStats, defaultRenderGamesPanel, defaultRenderVariationsStrip, defaultRenderBoardNav, DefaultBoardNav, } from "./defaults";
|
|
8
|
+
export type { ReferenceLayoutConfig } from "./referenceLayout";
|
|
9
|
+
export { GameReplayTrainer, type GameReplayTrainerProps, } from "./GameReplayTrainer";
|
|
10
|
+
export { useGameReplayTraining } from "./hooks/useGameReplayTraining";
|
|
11
|
+
export type { PositionApiDto, PositionGamesApiDto, PositionGameRowApiDto, PositionMoveApiDto, PositionVariationLineApiDto, PositionVariationsApiDto, FetchPositionGamesParams, FetchPositionVariationsParams, ExplorerGameReplayApiDto, } from "./types";
|
|
12
|
+
export { mockFetchPosition, mockFetchPositionGames, mockFetchPositionVariations, } from "./mocks";
|
|
13
|
+
export { applyLineSans, fenAfterUci, normalizeFen, whiteScorePercent, } from "./positionUtils";
|
|
14
|
+
export { isVariationLineActive } from "./variationLines";
|
|
15
|
+
export { findPlyIndexForFen, fenAtPly } from "./gameReplayUtils";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FetchPositionGamesParams, FetchPositionVariationsParams, PositionApiDto, PositionGamesApiDto, PositionVariationsApiDto } from "./types";
|
|
2
|
+
export declare function mockFetchPosition(fen: string): Promise<PositionApiDto | null>;
|
|
3
|
+
export declare function mockFetchPositionVariations(params: FetchPositionVariationsParams): Promise<PositionVariationsApiDto | null>;
|
|
4
|
+
export declare function mockFetchPositionGames(params: FetchPositionGamesParams): Promise<PositionGamesApiDto>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Match endchess-backend / mass-games-import (first four FEN fields). */
|
|
2
|
+
export declare function normalizeFen(fen: string): string;
|
|
3
|
+
export type BoardMoveResult = {
|
|
4
|
+
fen: string;
|
|
5
|
+
uci: string;
|
|
6
|
+
san: string;
|
|
7
|
+
};
|
|
8
|
+
/** Legal move from a board drag/drop (react-chessboard piece string, e.g. wQ). */
|
|
9
|
+
export declare function applyBoardMove(fen: string, sourceSquare: string, targetSquare: string, piece: string): BoardMoveResult | null;
|
|
10
|
+
export type LineSansEntry = {
|
|
11
|
+
fen: string;
|
|
12
|
+
lastSan: string;
|
|
13
|
+
};
|
|
14
|
+
/** Play a SAN sequence from a start FEN; returns null if any move is illegal. */
|
|
15
|
+
export declare function applyLineSans(startFen: string, sans: string[]): {
|
|
16
|
+
fen: string;
|
|
17
|
+
entries: LineSansEntry[];
|
|
18
|
+
} | null;
|
|
19
|
+
/** Apply a UCI move to a FEN; returns null if illegal. */
|
|
20
|
+
export declare function fenAfterUci(fen: string, uci: string): string | null;
|
|
21
|
+
export declare function whiteScorePercent(whiteWins: number, draws: number, blackWins: number): number | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** ChessBase Reference–style proportions: wide board column, narrower data column. */
|
|
2
|
+
export type ReferenceLayoutConfig = {
|
|
3
|
+
/** Pixel width passed to HighlightChessboard (left column centers the board). */
|
|
4
|
+
boardWidth: number;
|
|
5
|
+
/** CSS grid track for the board column. */
|
|
6
|
+
boardColumn: string;
|
|
7
|
+
/** CSS grid track for the reference panel. */
|
|
8
|
+
referenceColumn: string;
|
|
9
|
+
columnGap: number;
|
|
10
|
+
/** Shell height when {@link PositionReferenceExplorerProps.fillHeight} is true. */
|
|
11
|
+
minHeight: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const DEFAULT_REFERENCE_LAYOUT: ReferenceLayoutConfig;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/** Align with endchess-backend GET /positions */
|
|
2
|
+
export type PositionMoveApiDto = {
|
|
3
|
+
san: string;
|
|
4
|
+
uci: string;
|
|
5
|
+
games: number;
|
|
6
|
+
whiteWins: number;
|
|
7
|
+
draws: number;
|
|
8
|
+
blackWins: number;
|
|
9
|
+
avgElo: number | null;
|
|
10
|
+
};
|
|
11
|
+
export type PositionApiDto = {
|
|
12
|
+
positionKey: string;
|
|
13
|
+
fen: string;
|
|
14
|
+
totalGames: number;
|
|
15
|
+
moves: PositionMoveApiDto[];
|
|
16
|
+
sampleGameIds: string[];
|
|
17
|
+
};
|
|
18
|
+
/** Align with endchess-backend GET /positions/games */
|
|
19
|
+
export type PositionGameRowApiDto = {
|
|
20
|
+
gameId: string;
|
|
21
|
+
url: string;
|
|
22
|
+
white: string;
|
|
23
|
+
black: string;
|
|
24
|
+
whiteElo: number;
|
|
25
|
+
blackElo: number;
|
|
26
|
+
result: string;
|
|
27
|
+
date?: string;
|
|
28
|
+
event?: string;
|
|
29
|
+
timeControl?: string;
|
|
30
|
+
timeClass?: string;
|
|
31
|
+
nextSan: string;
|
|
32
|
+
nextUci: string;
|
|
33
|
+
avgElo: number;
|
|
34
|
+
};
|
|
35
|
+
export type PositionGamesApiDto = {
|
|
36
|
+
positionKey: string;
|
|
37
|
+
fen: string;
|
|
38
|
+
minElo: number;
|
|
39
|
+
maxElo: number;
|
|
40
|
+
uci?: string;
|
|
41
|
+
topOnly: boolean;
|
|
42
|
+
games: PositionGameRowApiDto[];
|
|
43
|
+
};
|
|
44
|
+
export type FetchPositionGamesParams = {
|
|
45
|
+
fen: string;
|
|
46
|
+
minElo: number;
|
|
47
|
+
maxElo: number;
|
|
48
|
+
uci?: string;
|
|
49
|
+
topOnly: boolean;
|
|
50
|
+
limit?: number;
|
|
51
|
+
};
|
|
52
|
+
/** Align with endchess-backend GET /positions/variations */
|
|
53
|
+
export type PositionVariationLineApiDto = {
|
|
54
|
+
key: string;
|
|
55
|
+
label: string;
|
|
56
|
+
moves: PositionMoveApiDto[];
|
|
57
|
+
uciPath: string[];
|
|
58
|
+
games: number;
|
|
59
|
+
scorePercent: number | null;
|
|
60
|
+
lastPlayedYear: number | null;
|
|
61
|
+
avgElo: number | null;
|
|
62
|
+
};
|
|
63
|
+
export type PositionVariationsApiDto = {
|
|
64
|
+
positionKey: string;
|
|
65
|
+
fen: string;
|
|
66
|
+
mode: "variations" | "popularity";
|
|
67
|
+
depth: number;
|
|
68
|
+
lineCount: number;
|
|
69
|
+
minElo: number;
|
|
70
|
+
maxElo: number;
|
|
71
|
+
lines: PositionVariationLineApiDto[];
|
|
72
|
+
};
|
|
73
|
+
export type FetchPositionVariationsParams = {
|
|
74
|
+
fen: string;
|
|
75
|
+
mode: "variations" | "popularity";
|
|
76
|
+
minElo: number;
|
|
77
|
+
maxElo: number;
|
|
78
|
+
depth?: number;
|
|
79
|
+
lineCount?: number;
|
|
80
|
+
};
|
|
81
|
+
/** Align with endchess-backend GET /positions/games/:gameId */
|
|
82
|
+
export type ExplorerGameReplayApiDto = {
|
|
83
|
+
gameId: string;
|
|
84
|
+
url: string;
|
|
85
|
+
white: string;
|
|
86
|
+
black: string;
|
|
87
|
+
whiteElo: number;
|
|
88
|
+
blackElo: number;
|
|
89
|
+
result: string;
|
|
90
|
+
date?: string;
|
|
91
|
+
event?: string;
|
|
92
|
+
timeControl?: string;
|
|
93
|
+
timeClass?: string;
|
|
94
|
+
movesUci: string[];
|
|
95
|
+
movesSan: string[];
|
|
96
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PositionVariationLineApiDto } from "./types";
|
|
2
|
+
export type VariationsTab = "variations" | "popularity" | "endgames";
|
|
3
|
+
/** @deprecated Use PositionVariationLineApiDto from ./types */
|
|
4
|
+
export type PositionVariationLine = PositionVariationLineApiDto;
|
|
5
|
+
export declare function isVariationLineActive(line: PositionVariationLineApiDto, selectedLineKey?: string, forwardSans?: string[]): boolean;
|
package/dist/index.d.ts
ADDED