react-chess-explorer 0.0.2 → 0.0.3
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 -21
- package/README.md +63 -63
- package/dist/features/explorer/components/DefaultBoardNav.d.ts +2 -7
- package/dist/features/explorer/components/PositionGamesPanel.d.ts +2 -9
- package/dist/features/explorer/core/PositionReferenceExplorerCore.d.ts +1 -1
- package/dist/features/explorer/core/renderProps.d.ts +22 -15
- package/dist/features/explorer/defaults/DefaultReferencePanel.d.ts +2 -1
- package/dist/features/explorer/defaults/DefaultVariationsStrip.d.ts +1 -1
- package/dist/features/explorer/explorerSessionCache.d.ts +15 -0
- package/dist/features/explorer/hooks/useExplorerPrefetch.d.ts +11 -0
- package/dist/features/explorer/hooks/usePositionHistory.d.ts +12 -1
- package/dist/features/explorer/hooks/usePositionReferenceData.d.ts +11 -14
- package/dist/features/explorer/hooks/useVariationLines.d.ts +1 -5
- package/dist/features/explorer/index.d.ts +4 -3
- package/dist/features/explorer/mocks.d.ts +2 -2
- package/dist/features/explorer/positionUtils.d.ts +2 -0
- package/dist/features/explorer/seedExplorerStartSession.d.ts +3 -0
- package/dist/features/explorer/types.d.ts +13 -10
- package/dist/features/explorer/variationLines.d.ts +0 -1
- package/dist/index.esm.js +666 -292
- package/dist/index.js +676 -290
- package/dist/stories/fixtures/nc6MockApi.d.ts +2 -2
- package/dist/stories/fixtures/nc6SampleGames.d.ts +0 -3
- package/package.json +59 -59
- package/dist/features/explorer/components/EloRangeFilter.d.ts +0 -9
- package/dist/features/explorer/components/LineHeader.d.ts +0 -4
package/LICENSE
CHANGED
|
@@ -1,21 +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.
|
|
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
CHANGED
|
@@ -1,63 +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
|
|
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
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
canGoForward: boolean;
|
|
4
|
-
onBack: () => void;
|
|
5
|
-
onForward: () => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const DefaultBoardNav: ({ canGoBack, canGoForward, onBack, onForward, }: BoardNavRenderProps) => import("react").JSX.Element;
|
|
1
|
+
import type { BoardNavRenderProps } from "../core/renderProps";
|
|
2
|
+
export declare const DefaultBoardNav: ({ canGoBack, canGoForward, onBack, onForward, onFlipBoard, }: BoardNavRenderProps) => import("react").JSX.Element;
|
|
8
3
|
export declare const defaultRenderBoardNav: (props: BoardNavRenderProps) => import("react").JSX.Element;
|
|
@@ -2,16 +2,9 @@ import type { GameSource, PositionGameRowApiDto } from "../types";
|
|
|
2
2
|
export type PositionGamesPanelProps = {
|
|
3
3
|
games: PositionGameRowApiDto[];
|
|
4
4
|
lineLabel: string;
|
|
5
|
-
|
|
6
|
-
maxElo: number;
|
|
7
|
-
defaultMinElo: number;
|
|
8
|
-
defaultMaxElo: number;
|
|
9
|
-
topOnly: boolean;
|
|
5
|
+
lineSans: string[];
|
|
10
6
|
sources: GameSource[];
|
|
11
|
-
onMinEloChange: (value: number) => void;
|
|
12
|
-
onMaxEloChange: (value: number) => void;
|
|
13
|
-
onTopOnlyChange: (value: boolean) => void;
|
|
14
7
|
onSourcesChange: (sources: GameSource[]) => void;
|
|
15
8
|
onGameSelect?: (game: PositionGameRowApiDto) => void;
|
|
16
9
|
};
|
|
17
|
-
export declare const PositionGamesPanel: ({ games, lineLabel,
|
|
10
|
+
export declare const PositionGamesPanel: ({ games, lineLabel, lineSans: _lineSans, sources, onSourcesChange, onGameSelect, }: PositionGamesPanelProps) => import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PositionReferenceExplorerCoreProps } from "./renderProps";
|
|
2
|
-
export declare const PositionReferenceExplorerCore: ({ fen: fenProp, onFenChange, initialLineSans, onLineSansChange, fetchPosition, fetchPositionGames, fetchPositionVariations, theme, boardWidth,
|
|
2
|
+
export declare const PositionReferenceExplorerCore: ({ fen: fenProp, onFenChange, initialLineSans, onLineSansChange, fetchPosition, fetchPositionGames, fetchPositionVariations, theme, boardTheme, boardWidth, boardOrientation: boardOrientationProp, defaultBoardOrientation, onBoardOrientationChange, fillHeight, layoutMinHeight, renderLayout, renderStatus, renderMoveStats, renderVariationsStrip, renderGamesPanel, renderBoardNav, onGameSelect, keyboardNav, }: PositionReferenceExplorerCoreProps) => import("react").JSX.Element;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { FetchPositionGamesParams, FetchPositionVariationsParams, GameSource, PositionApiDto, PositionGameRowApiDto, PositionGamesApiDto, PositionMoveApiDto, PositionVariationLineApiDto, PositionVariationsApiDto } from "../types";
|
|
3
|
-
import type {
|
|
2
|
+
import type { FetchPositionGamesParams, FetchPositionParams, FetchPositionVariationsParams, GameSource, PositionApiDto, PositionGameRowApiDto, PositionGamesApiDto, PositionMoveApiDto, PositionVariationLineApiDto, PositionVariationsApiDto } from "../types";
|
|
3
|
+
import type { BoardThemeId } from "react-chess-core";
|
|
4
4
|
export type ReferenceLayoutRenderProps = {
|
|
5
5
|
theme: "light" | "dark";
|
|
6
6
|
board: ReactNode;
|
|
7
7
|
referencePanel: ReactNode;
|
|
8
8
|
};
|
|
9
|
+
export type BoardOrientation = "white" | "black";
|
|
9
10
|
export type BoardNavRenderProps = {
|
|
10
11
|
canGoBack: boolean;
|
|
11
12
|
canGoForward: boolean;
|
|
12
13
|
onBack: () => void;
|
|
13
14
|
onForward: () => void;
|
|
15
|
+
boardOrientation: BoardOrientation;
|
|
16
|
+
onFlipBoard: () => void;
|
|
14
17
|
};
|
|
15
18
|
export type ExplorerStatusRenderProps = {
|
|
16
19
|
error: string | null;
|
|
@@ -28,23 +31,15 @@ export type LineHeaderRenderProps = {
|
|
|
28
31
|
export type GamesPanelRenderProps = {
|
|
29
32
|
games: PositionGameRowApiDto[];
|
|
30
33
|
lineLabel: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
defaultMinElo: number;
|
|
34
|
-
defaultMaxElo: number;
|
|
35
|
-
topOnly: boolean;
|
|
34
|
+
lineSans: string[];
|
|
35
|
+
loading?: boolean;
|
|
36
36
|
sources: GameSource[];
|
|
37
|
-
onMinEloChange: (value: number) => void;
|
|
38
|
-
onMaxEloChange: (value: number) => void;
|
|
39
|
-
onTopOnlyChange: (value: boolean) => void;
|
|
40
37
|
onSourcesChange: (sources: GameSource[]) => void;
|
|
41
38
|
/** Start replay training for a database game from the current board FEN. */
|
|
42
39
|
onGameSelect?: (game: PositionGameRowApiDto) => void;
|
|
43
40
|
};
|
|
44
41
|
export type VariationsStripRenderProps = {
|
|
45
42
|
theme: "light" | "dark";
|
|
46
|
-
tab: VariationsTab;
|
|
47
|
-
onTabChange: (tab: VariationsTab) => void;
|
|
48
43
|
lines: PositionVariationLineApiDto[];
|
|
49
44
|
loading: boolean;
|
|
50
45
|
selectedLineKey?: string;
|
|
@@ -58,13 +53,20 @@ export type PositionReferenceExplorerCoreProps = {
|
|
|
58
53
|
initialLineSans?: string[];
|
|
59
54
|
/** Fired after mount when the played SAN line changes (back/forward/new move). */
|
|
60
55
|
onLineSansChange?: (lineSans: string[]) => void;
|
|
61
|
-
fetchPosition: (
|
|
56
|
+
fetchPosition: (params: FetchPositionParams) => Promise<PositionApiDto | null>;
|
|
62
57
|
fetchPositionGames: (params: FetchPositionGamesParams) => Promise<PositionGamesApiDto>;
|
|
63
58
|
fetchPositionVariations: (params: FetchPositionVariationsParams) => Promise<PositionVariationsApiDto | null>;
|
|
64
59
|
theme?: "light" | "dark";
|
|
60
|
+
boardTheme?: BoardThemeId;
|
|
61
|
+
/** Reserved for board move sounds (wired when react-chess-core supports it). */
|
|
62
|
+
boardSoundsEnabled?: boolean;
|
|
65
63
|
boardWidth?: number;
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
/** Controlled board orientation. When omitted, orientation is managed internally. */
|
|
65
|
+
boardOrientation?: BoardOrientation;
|
|
66
|
+
/** Initial orientation when uncontrolled. Defaults to white. */
|
|
67
|
+
defaultBoardOrientation?: BoardOrientation;
|
|
68
|
+
/** Fired when the user flips the board (controlled or uncontrolled). */
|
|
69
|
+
onBoardOrientationChange?: (orientation: BoardOrientation) => void;
|
|
68
70
|
/** When true, shell uses full viewport height (no extra content below the grid). */
|
|
69
71
|
fillHeight?: boolean;
|
|
70
72
|
layoutMinHeight?: string;
|
|
@@ -76,4 +78,9 @@ export type PositionReferenceExplorerCoreProps = {
|
|
|
76
78
|
renderBoardNav?: (props: BoardNavRenderProps) => ReactNode;
|
|
77
79
|
/** When set, games panel can launch per-game replay training. */
|
|
78
80
|
onGameSelect?: (game: PositionGameRowApiDto) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Register ArrowLeft/ArrowRight/Home/End shortcuts while the explorer is mounted.
|
|
83
|
+
* Default true.
|
|
84
|
+
*/
|
|
85
|
+
keyboardNav?: boolean;
|
|
79
86
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
export type DefaultReferencePanelProps = {
|
|
3
3
|
theme: "light" | "dark";
|
|
4
|
+
fillHeight?: boolean;
|
|
4
5
|
status: ReactNode;
|
|
5
6
|
moveStats: ReactNode;
|
|
6
7
|
variationsStrip: ReactNode;
|
|
7
8
|
gamesPanel: ReactNode;
|
|
8
9
|
};
|
|
9
10
|
/** 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;
|
|
11
|
+
export declare const DefaultReferencePanel: ({ theme, fillHeight, status, moveStats, variationsStrip, gamesPanel, }: DefaultReferencePanelProps) => import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VariationsStripRenderProps } from "../core/renderProps";
|
|
2
|
-
export declare const DefaultVariationsStrip: ({ theme,
|
|
2
|
+
export declare const DefaultVariationsStrip: ({ theme, lines, loading, selectedLineKey, forwardSans, onLineSelect, }: VariationsStripRenderProps) => import("react").JSX.Element;
|
|
3
3
|
export declare const defaultRenderVariationsStrip: (props: VariationsStripRenderProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FetchPositionGamesParams, PositionGamesApiDto, PositionVariationLineApiDto } from "./types";
|
|
2
|
+
export declare const EXPLORER_PREFETCH_CHILD_COUNT = 4;
|
|
3
|
+
export declare const EXPLORER_DEFAULT_VARIATION_LINE_COUNT = 8;
|
|
4
|
+
export declare const EXPLORER_DEFAULT_VARIATION_DEPTH = 4;
|
|
5
|
+
export declare function gamesSessionKey(params: FetchPositionGamesParams): string;
|
|
6
|
+
export declare function variationsSessionKey(fen: string, lineCount?: number, lineDepth?: number): string;
|
|
7
|
+
type SessionCacheListener = () => void;
|
|
8
|
+
export declare function subscribeExplorerSessionCache(listener: SessionCacheListener): () => void;
|
|
9
|
+
export declare function peekSessionGames(key: string): PositionGamesApiDto | undefined;
|
|
10
|
+
export declare function setSessionGames(key: string, data: PositionGamesApiDto): void;
|
|
11
|
+
export declare function peekSessionVariations(key: string): PositionVariationLineApiDto[] | undefined;
|
|
12
|
+
export declare function setSessionVariations(key: string, lines: PositionVariationLineApiDto[]): void;
|
|
13
|
+
/** @internal Test-only: drop in-memory session caches. */
|
|
14
|
+
export declare function clearExplorerSessionCacheForTests(): void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FetchPositionGamesParams, FetchPositionVariationsParams, GameSource, PositionGamesApiDto, PositionMoveApiDto, PositionVariationsApiDto } from "../types";
|
|
2
|
+
export type UseExplorerPrefetchOptions = {
|
|
3
|
+
fen: string;
|
|
4
|
+
moves: PositionMoveApiDto[];
|
|
5
|
+
positionReady: boolean;
|
|
6
|
+
sources: GameSource[];
|
|
7
|
+
fetchPositionGames: (params: FetchPositionGamesParams) => Promise<PositionGamesApiDto>;
|
|
8
|
+
fetchPositionVariations?: (params: FetchPositionVariationsParams) => Promise<PositionVariationsApiDto | null>;
|
|
9
|
+
childCount?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function useExplorerPrefetch({ fen, moves, positionReady, sources, fetchPositionGames, fetchPositionVariations, childCount, }: UseExplorerPrefetchOptions): void;
|
|
@@ -3,17 +3,28 @@ export type PositionHistoryEntry = {
|
|
|
3
3
|
/** SAN of the move played from the previous entry to reach this FEN. */
|
|
4
4
|
lastSan?: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function initialHistoryState(initialFen: string, initialLineSans?: string[]): {
|
|
7
|
+
history: PositionHistoryEntry[];
|
|
8
|
+
historyIndex: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function usePositionHistory(initialFen: string, initialLineSans?: string[]): {
|
|
7
11
|
canGoBack: boolean;
|
|
8
12
|
canGoForward: boolean;
|
|
9
13
|
lineSans: string[];
|
|
10
14
|
forwardSans: string[];
|
|
15
|
+
currentFen: string;
|
|
11
16
|
pushEntry: (fen: string, lastSan?: string) => PositionHistoryEntry;
|
|
12
17
|
pushEntries: (entries: {
|
|
13
18
|
fen: string;
|
|
14
19
|
lastSan: string;
|
|
15
20
|
}[]) => void;
|
|
21
|
+
replaceLineEntries: (startFen: string, entries: {
|
|
22
|
+
fen: string;
|
|
23
|
+
lastSan: string;
|
|
24
|
+
}[]) => void;
|
|
16
25
|
goBack: () => PositionHistoryEntry | null;
|
|
17
26
|
goForward: () => PositionHistoryEntry | null;
|
|
27
|
+
goFirst: () => PositionHistoryEntry | null;
|
|
28
|
+
goLast: () => PositionHistoryEntry | null;
|
|
18
29
|
resetHistory: (fen: string) => PositionHistoryEntry;
|
|
19
30
|
};
|
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
import { type FetchPositionGamesParams, type GameSource, type PositionApiDto, type PositionGamesApiDto, type PositionMoveApiDto } from "../types";
|
|
1
|
+
import { type FetchPositionGamesParams, type FetchPositionParams, type FetchPositionVariationsParams, type GameSource, type PositionApiDto, type PositionGamesApiDto, type PositionMoveApiDto, type PositionVariationsApiDto } from "../types";
|
|
2
2
|
import type { PositionVariationLineApiDto } from "../types";
|
|
3
|
-
import type { VariationsTab } from "../variationLines";
|
|
4
3
|
export type UsePositionReferenceDataOptions = {
|
|
5
4
|
fenProp?: string;
|
|
6
5
|
onFenChange?: (fen: string) => void;
|
|
7
6
|
initialLineSans?: string[];
|
|
8
7
|
onLineSansChange?: (lineSans: string[]) => void;
|
|
9
|
-
fetchPosition: (
|
|
8
|
+
fetchPosition: (params: FetchPositionParams) => Promise<PositionApiDto | null>;
|
|
10
9
|
fetchPositionGames: (params: FetchPositionGamesParams) => Promise<PositionGamesApiDto>;
|
|
11
|
-
|
|
12
|
-
defaultMaxElo: number;
|
|
10
|
+
fetchPositionVariations?: (params: FetchPositionVariationsParams) => Promise<PositionVariationsApiDto | null>;
|
|
13
11
|
};
|
|
14
|
-
export declare function usePositionReferenceData({ fenProp, onFenChange, initialLineSans, onLineSansChange, fetchPosition, fetchPositionGames,
|
|
12
|
+
export declare function usePositionReferenceData({ fenProp, onFenChange, initialLineSans, onLineSansChange, fetchPosition, fetchPositionGames, fetchPositionVariations, }: UsePositionReferenceDataOptions): {
|
|
15
13
|
fen: string;
|
|
16
14
|
boardFen: string;
|
|
17
15
|
position: PositionApiDto | null;
|
|
18
16
|
games: PositionGamesApiDto | null;
|
|
19
17
|
gamesMoveFilterUci: string | undefined;
|
|
20
|
-
minElo: number;
|
|
21
|
-
maxElo: number;
|
|
22
|
-
topOnly: boolean;
|
|
23
18
|
sources: GameSource[];
|
|
19
|
+
lineSans: string[];
|
|
24
20
|
loading: boolean;
|
|
21
|
+
showPositionLoading: boolean;
|
|
22
|
+
gamesLoading: boolean;
|
|
23
|
+
positionReady: boolean;
|
|
24
|
+
displayMoves: PositionMoveApiDto[];
|
|
25
25
|
error: string | null;
|
|
26
26
|
lineLabel: string;
|
|
27
27
|
canGoBack: boolean;
|
|
28
28
|
canGoForward: boolean;
|
|
29
|
-
variationsTab: VariationsTab;
|
|
30
29
|
forwardSans: string[];
|
|
31
30
|
selectedVariationKey: string | undefined;
|
|
32
|
-
setMinElo: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
33
|
-
setMaxElo: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
34
|
-
setTopOnly: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
35
31
|
setSources: import("react").Dispatch<import("react").SetStateAction<GameSource[]>>;
|
|
36
|
-
setVariationsTab: import("react").Dispatch<import("react").SetStateAction<VariationsTab>>;
|
|
37
32
|
setGamesMoveFilterUci: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
38
33
|
handleMoveSelect: (move: PositionMoveApiDto) => void;
|
|
39
34
|
handleLineSelect: (line: PositionVariationLineApiDto) => void;
|
|
40
35
|
handlePieceDrop: (sourceSquare: string, targetSquare: string, piece: string) => boolean;
|
|
41
36
|
handleBack: () => void;
|
|
42
37
|
handleForward: () => void;
|
|
38
|
+
handleFirst: () => void;
|
|
39
|
+
handleLast: () => void;
|
|
43
40
|
};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import type { FetchPositionVariationsParams, PositionVariationLineApiDto, PositionVariationsApiDto } from "../types";
|
|
2
|
-
import type { VariationsTab } from "../variationLines";
|
|
3
2
|
export type UseVariationLinesOptions = {
|
|
4
3
|
fen: string;
|
|
5
|
-
tab: VariationsTab;
|
|
6
|
-
minElo: number;
|
|
7
|
-
maxElo: number;
|
|
8
4
|
fetchPositionVariations: (params: FetchPositionVariationsParams) => Promise<PositionVariationsApiDto | null>;
|
|
9
5
|
lineCount?: number;
|
|
10
6
|
lineDepth?: number;
|
|
11
7
|
enabled?: boolean;
|
|
12
8
|
};
|
|
13
|
-
export declare function useVariationLines({ fen,
|
|
9
|
+
export declare function useVariationLines({ fen, fetchPositionVariations, lineCount, lineDepth, enabled, }: UseVariationLinesOptions): {
|
|
14
10
|
lines: PositionVariationLineApiDto[];
|
|
15
11
|
loading: boolean;
|
|
16
12
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
export { EXPLORER_START_FEN } from "./constants";
|
|
2
|
+
export { seedExplorerStartSession } from "./seedExplorerStartSession";
|
|
3
|
+
export { EXPLORER_DEFAULT_VARIATION_DEPTH, EXPLORER_DEFAULT_VARIATION_LINE_COUNT, EXPLORER_PREFETCH_CHILD_COUNT, gamesSessionKey, peekSessionGames, peekSessionVariations, setSessionGames, setSessionVariations, subscribeExplorerSessionCache, variationsSessionKey, } from "./explorerSessionCache";
|
|
2
4
|
export { ExplorerPlaceholder, type ExplorerPlaceholderProps, } from "./ExplorerPlaceholder";
|
|
3
5
|
export { PositionReferenceExplorer, type PositionReferenceExplorerProps, } from "./PositionReferenceExplorer";
|
|
4
6
|
export { PositionReferenceExplorerCore } from "./core/PositionReferenceExplorerCore";
|
|
5
7
|
export type { PositionReferenceExplorerCoreProps, ReferenceLayoutRenderProps, ExplorerStatusRenderProps, MoveStatsRenderProps, GamesPanelRenderProps, VariationsStripRenderProps, BoardNavRenderProps, } from "./core/renderProps";
|
|
6
|
-
export type { VariationsTab } from "./variationLines";
|
|
7
8
|
export { DEFAULT_REFERENCE_LAYOUT, DefaultReferenceLayout, DefaultReferencePanel, DefaultVariationsStrip, defaultRenderLayout, defaultRenderStatus, defaultRenderMoveStats, defaultRenderGamesPanel, defaultRenderVariationsStrip, defaultRenderBoardNav, DefaultBoardNav, } from "./defaults";
|
|
8
9
|
export type { ReferenceLayoutConfig } from "./referenceLayout";
|
|
9
10
|
export { GameReplayTrainer, type GameReplayTrainerProps, } from "./GameReplayTrainer";
|
|
10
11
|
export { useGameReplayTraining } from "./hooks/useGameReplayTraining";
|
|
11
|
-
export type { GameSource, PositionApiDto, PositionGamesApiDto, PositionGameRowApiDto, PositionMoveApiDto, PositionVariationLineApiDto, PositionVariationsApiDto, FetchPositionGamesParams, FetchPositionVariationsParams, ExplorerGameReplayApiDto, } from "./types";
|
|
12
|
+
export type { GameSource, PositionApiDto, PositionGamesApiDto, PositionGameRowApiDto, PositionMoveApiDto, PositionVariationLineApiDto, PositionVariationsApiDto, FetchPositionParams, FetchPositionGamesParams, FetchPositionVariationsParams, ExplorerGameReplayApiDto, } from "./types";
|
|
12
13
|
export { ALL_GAME_SOURCES } from "./types";
|
|
13
14
|
export { mockFetchPosition, mockFetchPositionGames, mockFetchPositionVariations, } from "./mocks";
|
|
14
|
-
export { applyLineSans, fenAfterUci, normalizeFen, whiteScorePercent, } from "./positionUtils";
|
|
15
|
+
export { applyLineSans, fenAfterUci, formatNumberedLineSans, normalizeFen, whiteScorePercent, } from "./positionUtils";
|
|
15
16
|
export { isVariationLineActive } from "./variationLines";
|
|
16
17
|
export { findPlyIndexForFen, fenAtPly } from "./gameReplayUtils";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FetchPositionGamesParams, FetchPositionVariationsParams, PositionApiDto, PositionGamesApiDto, PositionVariationsApiDto } from "./types";
|
|
2
|
-
export declare function mockFetchPosition(
|
|
1
|
+
import type { FetchPositionGamesParams, FetchPositionParams, FetchPositionVariationsParams, PositionApiDto, PositionGamesApiDto, PositionVariationsApiDto } from "./types";
|
|
2
|
+
export declare function mockFetchPosition(params: FetchPositionParams): Promise<PositionApiDto | null>;
|
|
3
3
|
export declare function mockFetchPositionVariations(params: FetchPositionVariationsParams): Promise<PositionVariationsApiDto | null>;
|
|
4
4
|
export declare function mockFetchPositionGames(params: FetchPositionGamesParams): Promise<PositionGamesApiDto>;
|
|
@@ -19,3 +19,5 @@ export declare function applyLineSans(startFen: string, sans: string[]): {
|
|
|
19
19
|
/** Apply a UCI move to a FEN; returns null if illegal. */
|
|
20
20
|
export declare function fenAfterUci(fen: string, uci: string): string | null;
|
|
21
21
|
export declare function whiteScorePercent(whiteWins: number, draws: number, blackWins: number): number | null;
|
|
22
|
+
/** Format SAN plies from the starting position as `1.d4 Nf6 2.c4 e6`. */
|
|
23
|
+
export declare function formatNumberedLineSans(sans: string[]): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PositionGamesApiDto, PositionVariationsApiDto } from "./types";
|
|
2
|
+
/** Push start-hub payloads into the explorer session cache (used by app preload). */
|
|
3
|
+
export declare function seedExplorerStartSession(games: PositionGamesApiDto, variations: PositionVariationsApiDto): void;
|
|
@@ -37,19 +37,22 @@ export type PositionGameRowApiDto = {
|
|
|
37
37
|
export type PositionGamesApiDto = {
|
|
38
38
|
positionKey: string;
|
|
39
39
|
fen: string;
|
|
40
|
-
minElo: number;
|
|
41
|
-
maxElo: number;
|
|
42
40
|
uci?: string;
|
|
43
|
-
|
|
41
|
+
offset: number;
|
|
42
|
+
hasMore: boolean;
|
|
44
43
|
games: PositionGameRowApiDto[];
|
|
45
44
|
};
|
|
45
|
+
export type FetchPositionParams = {
|
|
46
|
+
fen: string;
|
|
47
|
+
minElo?: number;
|
|
48
|
+
maxElo?: number;
|
|
49
|
+
sources?: GameSource[];
|
|
50
|
+
};
|
|
46
51
|
export type FetchPositionGamesParams = {
|
|
47
52
|
fen: string;
|
|
48
|
-
minElo: number;
|
|
49
|
-
maxElo: number;
|
|
50
53
|
uci?: string;
|
|
51
|
-
topOnly: boolean;
|
|
52
54
|
limit?: number;
|
|
55
|
+
offset?: number;
|
|
53
56
|
sources?: GameSource[];
|
|
54
57
|
};
|
|
55
58
|
/** Align with endchess-backend GET /positions/variations */
|
|
@@ -69,15 +72,15 @@ export type PositionVariationsApiDto = {
|
|
|
69
72
|
mode: "variations" | "popularity";
|
|
70
73
|
depth: number;
|
|
71
74
|
lineCount: number;
|
|
72
|
-
minElo
|
|
73
|
-
maxElo
|
|
75
|
+
minElo?: number;
|
|
76
|
+
maxElo?: number;
|
|
74
77
|
lines: PositionVariationLineApiDto[];
|
|
75
78
|
};
|
|
76
79
|
export type FetchPositionVariationsParams = {
|
|
77
80
|
fen: string;
|
|
78
81
|
mode: "variations" | "popularity";
|
|
79
|
-
minElo
|
|
80
|
-
maxElo
|
|
82
|
+
minElo?: number;
|
|
83
|
+
maxElo?: number;
|
|
81
84
|
depth?: number;
|
|
82
85
|
lineCount?: number;
|
|
83
86
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { PositionVariationLineApiDto } from "./types";
|
|
2
|
-
export type VariationsTab = "variations" | "popularity" | "endgames";
|
|
3
2
|
/** @deprecated Use PositionVariationLineApiDto from ./types */
|
|
4
3
|
export type PositionVariationLine = PositionVariationLineApiDto;
|
|
5
4
|
export declare function isVariationLineActive(line: PositionVariationLineApiDto, selectedLineKey?: string, forwardSans?: string[]): boolean;
|