react-chess-puzzle-kit 1.0.0 → 1.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 -21
- package/README.md +331 -331
- package/dist/features/analysis/analysisContext.d.ts +1 -1
- package/dist/features/board/LineBoardWithControls.d.ts +3 -1
- package/dist/features/board/PuzzleBoard.d.ts +6 -1
- package/dist/features/board/PuzzleBoardWithControls.d.ts +63 -6
- package/dist/features/board/PuzzlePlaySurface.d.ts +27 -3
- package/dist/features/board/puzzleBoardLayout.d.ts +17 -4
- package/dist/features/board/useStackPuzzleControlsBelow.d.ts +2 -0
- package/dist/features/position/Position.d.ts +18 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +416 -96
- package/dist/index.js +416 -94
- package/package.json +87 -87
- package/dist/features/analysis/AnalysisBoard.d.ts +0 -18
- package/dist/features/analysis/AnalysisBoardCore.d.ts +0 -28
- package/dist/features/analysis/AnalysisBoardLayout.d.ts +0 -12
- package/dist/features/analysis/AnalysisChessboardView.d.ts +0 -5
- package/dist/features/analysis/AnalysisPosition.d.ts +0 -53
- package/dist/features/analysis/AnalysisTrigger.d.ts +0 -6
- package/dist/features/analysis/DefaultAnalysisContainer.d.ts +0 -3
- package/dist/features/analysis/DefaultAnalysisSidebar.d.ts +0 -2
- package/dist/features/analysis/analysisBoardHighlightColors.d.ts +0 -12
- package/dist/features/analysis/analysisLayout.d.ts +0 -5
- package/dist/features/analysis/core/AnalysisBoardCore.d.ts +0 -28
- package/dist/features/analysis/core/AnalysisChessboardView.d.ts +0 -5
- package/dist/features/analysis/core/AnalysisErrorBoundary.d.ts +0 -14
- package/dist/features/analysis/core/AnalysisPosition.d.ts +0 -54
- package/dist/features/analysis/core/analysisContext.d.ts +0 -13
- package/dist/features/analysis/core/analysisLayout.d.ts +0 -5
- package/dist/features/analysis/core/analysisLayoutConfig.d.ts +0 -6
- package/dist/features/analysis/core/index.d.ts +0 -9
- package/dist/features/analysis/core/renderProps.d.ts +0 -39
- package/dist/features/analysis/core/useAnalysisBoardModel.d.ts +0 -36
- package/dist/features/analysis/core/usePuzzleAnalysis.d.ts +0 -10
- package/dist/features/analysis/defaults/AnalysisBoard.d.ts +0 -16
- package/dist/features/analysis/defaults/AnalysisBoardLayout.d.ts +0 -14
- package/dist/features/analysis/defaults/DefaultAnalysisContainer.d.ts +0 -4
- package/dist/features/analysis/defaults/DefaultAnalysisSidebar.d.ts +0 -3
- package/dist/features/analysis/defaults/analysisLayout.d.ts +0 -3
- package/dist/features/analysis/defaults/analysisModalStyles.d.ts +0 -7
- package/dist/features/analysis/defaults/analysisSidebarColors.d.ts +0 -37
- package/dist/features/analysis/defaults/analysisSidebarRowStyle.d.ts +0 -8
- package/dist/features/analysis/defaults/index.d.ts +0 -8
- package/dist/features/analysis/renderProps.d.ts +0 -39
- package/dist/features/analysis/useAnalysisBoardModel.d.ts +0 -33
- package/dist/features/board/HighlightChessboard.d.ts +0 -2
- package/dist/features/board/boardSquareHighlightColors.d.ts +0 -1
- package/dist/features/board/chessboardTheme.d.ts +0 -2
- package/dist/features/engine/EngineEvaluationPanel.d.ts +0 -8
- package/dist/features/engine/StockfishBrowserEngine.d.ts +0 -1
- package/dist/features/engine/formatEvaluation.d.ts +0 -1
- package/dist/features/engine/index.d.ts +0 -1
- package/dist/features/engine/isAnalyzableFen.d.ts +0 -1
- package/dist/features/engine/parseUciInfo.d.ts +0 -1
- package/dist/features/engine/stockfishUrls.d.ts +0 -1
- package/dist/features/engine/types.d.ts +0 -1
- package/dist/features/engine/useAnalysisEngine.d.ts +0 -1
- package/dist/features/theme/ThemeContext.d.ts +0 -26
- package/dist/features/theme/ThemeProvider.d.ts +0 -7
- package/dist/features/theme/squareHighlightColors.d.ts +0 -50
- package/dist/stories/AnalysisBoard.stories.d.ts +0 -9
- package/dist/stories/HighlightChessboard.stories.d.ts +0 -9
- package/dist/stories/analysisFixtures.d.ts +0 -4
- package/dist/stories/regressions/StockfishAnalysisRegressions.stories.d.ts +0 -7
- package/dist/stories/regressions/regressionAnalysisContext.d.ts +0 -5
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Move-list colors for the analysis board sidebar.
|
|
3
|
-
* Tweak values here when iterating on history row striping.
|
|
4
|
-
*/
|
|
5
|
-
export declare const analysisSidebarColors: {
|
|
6
|
-
/** Selected move row */
|
|
7
|
-
readonly activeMove: {
|
|
8
|
-
readonly light: "rgba(119, 177, 212, 1)";
|
|
9
|
-
readonly dark: "rgba(90, 159, 190, 1)";
|
|
10
|
-
};
|
|
11
|
-
/** Start row */
|
|
12
|
-
readonly start: {
|
|
13
|
-
readonly light: "#e8e8e8";
|
|
14
|
-
readonly dark: "#262626";
|
|
15
|
-
};
|
|
16
|
-
/** Alternating main-line rows (index 0 = darker, 1 = lighter). */
|
|
17
|
-
readonly mainStripe: readonly [{
|
|
18
|
-
readonly light: "#c9c9c9";
|
|
19
|
-
readonly dark: "#1c1c1c";
|
|
20
|
-
}, {
|
|
21
|
-
readonly light: "#f2f2f2";
|
|
22
|
-
readonly dark: "#383838";
|
|
23
|
-
}];
|
|
24
|
-
/** Alternating user-variation rows (index 0 = slightly tinted, 1 = lighter). */
|
|
25
|
-
readonly variationStripe: readonly [{
|
|
26
|
-
readonly light: "#eef5fb";
|
|
27
|
-
readonly dark: "#2c3540";
|
|
28
|
-
}, {
|
|
29
|
-
readonly light: "#f7fbfe";
|
|
30
|
-
readonly dark: "#343f4c";
|
|
31
|
-
}];
|
|
32
|
-
/** Text on variation rows (light backgrounds need dark type). */
|
|
33
|
-
readonly variationText: {
|
|
34
|
-
readonly light: "rgba(0, 0, 0, 0.87)";
|
|
35
|
-
readonly dark: "rgba(0, 0, 0, 0.87)";
|
|
36
|
-
};
|
|
37
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AnalysisHistoryRow } from '../core/AnalysisPosition';
|
|
2
|
-
export type SidebarRowBandCounters = {
|
|
3
|
-
main: number;
|
|
4
|
-
variation: number;
|
|
5
|
-
};
|
|
6
|
-
export declare const createSidebarRowBandCounters: () => SidebarRowBandCounters;
|
|
7
|
-
/** Background for one analysis history row; mutates `bands` while iterating rows in order. */
|
|
8
|
-
export declare const getSidebarRowBackground: (theme: "light" | "dark", row: AnalysisHistoryRow, bands: SidebarRowBandCounters) => string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './analysisModalStyles';
|
|
2
|
-
export * from './analysisSidebarColors';
|
|
3
|
-
export * from './analysisSidebarRowStyle';
|
|
4
|
-
export * from './analysisLayout';
|
|
5
|
-
export * from './AnalysisBoard';
|
|
6
|
-
export * from './AnalysisBoardLayout';
|
|
7
|
-
export * from './DefaultAnalysisContainer';
|
|
8
|
-
export * from './DefaultAnalysisSidebar';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { EngineEvaluation } from '../engine/types';
|
|
3
|
-
import { AnalysisHistoryRow, SolutionMoveDisplay } from './AnalysisPosition';
|
|
4
|
-
import { AnalysisBoardModel } from './useAnalysisBoardModel';
|
|
5
|
-
export type AnalysisControls = {
|
|
6
|
-
visible: boolean;
|
|
7
|
-
openAnalysis: () => void;
|
|
8
|
-
};
|
|
9
|
-
export type EngineEvaluationRenderProps = {
|
|
10
|
-
fen: string;
|
|
11
|
-
evaluation: EngineEvaluation;
|
|
12
|
-
theme: 'light' | 'dark';
|
|
13
|
-
};
|
|
14
|
-
export type AnalysisSidebarRenderProps = {
|
|
15
|
-
/** Main-line moves (legacy; prefer historyRows). */
|
|
16
|
-
moves: SolutionMoveDisplay[];
|
|
17
|
-
historyRows: AnalysisHistoryRow[];
|
|
18
|
-
isHistoryRowSelected: (row: AnalysisHistoryRow) => boolean;
|
|
19
|
-
onSelectHistoryRow: (row: AnalysisHistoryRow) => void;
|
|
20
|
-
ply: number;
|
|
21
|
-
maxPly: number;
|
|
22
|
-
onSelectPly: (ply: number) => void;
|
|
23
|
-
theme: 'light' | 'dark';
|
|
24
|
-
/** Host-rendered engine UI from `renderEngineEvaluation`. */
|
|
25
|
-
engineEvaluationPanel: ReactNode | null;
|
|
26
|
-
};
|
|
27
|
-
export type AnalysisContainerRenderProps = {
|
|
28
|
-
theme: 'light' | 'dark';
|
|
29
|
-
onClose: () => void;
|
|
30
|
-
children: ReactNode;
|
|
31
|
-
/** Used by {@link DefaultAnalysisContainer} for overlay dismiss (ignored by most hosts). */
|
|
32
|
-
onBackdropMouseDown?: () => void;
|
|
33
|
-
};
|
|
34
|
-
/** Place board + sidebar inside the analysis shell (host or default grid). */
|
|
35
|
-
export type AnalysisMainRenderProps = {
|
|
36
|
-
model: AnalysisBoardModel;
|
|
37
|
-
board: ReactNode;
|
|
38
|
-
sidebar: ReactNode;
|
|
39
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AnalysisHistoryRow, SolutionMoveDisplay } from './AnalysisPosition';
|
|
2
|
-
import { PuzzleAnalysisContext } from './analysisContext';
|
|
3
|
-
import { AnalysisEngineOptions, EngineEvaluation } from '../engine';
|
|
4
|
-
export type UseAnalysisBoardModelArgs = {
|
|
5
|
-
analysisContext: PuzzleAnalysisContext;
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
theme: 'light' | 'dark';
|
|
8
|
-
engine?: AnalysisEngineOptions;
|
|
9
|
-
};
|
|
10
|
-
export type AnalysisBoardModel = {
|
|
11
|
-
theme: 'light' | 'dark';
|
|
12
|
-
analysisContext: PuzzleAnalysisContext;
|
|
13
|
-
fen: string;
|
|
14
|
-
ply: number;
|
|
15
|
-
maxPly: number;
|
|
16
|
-
historyRows: AnalysisHistoryRow[];
|
|
17
|
-
solutionSans: SolutionMoveDisplay[];
|
|
18
|
-
boardOrientation: 'white' | 'black';
|
|
19
|
-
engineEvaluation: EngineEvaluation;
|
|
20
|
-
engineEnabled: boolean;
|
|
21
|
-
lastMove: {
|
|
22
|
-
from: string;
|
|
23
|
-
to: string;
|
|
24
|
-
} | null;
|
|
25
|
-
checkSquare: string | null;
|
|
26
|
-
onSelectPly: (ply: number) => void;
|
|
27
|
-
onSelectHistoryRow: (row: AnalysisHistoryRow) => void;
|
|
28
|
-
isHistoryRowSelected: (row: AnalysisHistoryRow) => boolean;
|
|
29
|
-
onPieceDrop: (sourceSquare: string, targetSquare: string, piece: string) => boolean;
|
|
30
|
-
onBackdropMouseDown: () => void;
|
|
31
|
-
onClose: () => void;
|
|
32
|
-
};
|
|
33
|
-
export declare const useAnalysisBoardModel: ({ analysisContext, onClose, theme, engine, }: UseAnalysisBoardModelArgs) => AnalysisBoardModel;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { boardSquareHighlightColors } from 'react-chess-core';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type EngineEvaluation } from 'react-chess-core';
|
|
3
|
-
export interface EngineEvaluationPanelProps {
|
|
4
|
-
fen: string;
|
|
5
|
-
evaluation: EngineEvaluation;
|
|
6
|
-
theme: 'light' | 'dark';
|
|
7
|
-
}
|
|
8
|
-
export declare const EngineEvaluationPanel: ({ fen, evaluation, theme, }: EngineEvaluationPanelProps) => React.JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { StockfishBrowserEngine } from 'react-chess-core';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { formatEvaluation, formatPvPreview, normalizeEvalForWhite, uciPvToSan, } from 'react-chess-core';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { EngineEvaluationPanel, type EngineEvaluationPanelProps, } from './EngineEvaluationPanel';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isAnalyzableFen } from 'react-chess-core';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { parseUciInfoLine } from 'react-chess-core';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { resolveStockfishScriptUrl, resolveStockfishWasmUrl, resolveStockfishWorkerUrl, } from 'react-chess-core';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from 'react-chess-core';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useAnalysisEngine } from 'react-chess-core';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CSSProperties } from 'react';
|
|
2
|
-
interface ThemeContextType {
|
|
3
|
-
customDarkSquareStyle: {
|
|
4
|
-
backgroundColor: string;
|
|
5
|
-
};
|
|
6
|
-
customLightSquareStyle: {
|
|
7
|
-
backgroundColor: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export declare const ThemeContext: import("react").Context<ThemeContextType | undefined>;
|
|
11
|
-
export declare const useTheme: () => ThemeContextType;
|
|
12
|
-
export declare const getStylesForTheme: (theme: "light" | "dark") => {
|
|
13
|
-
customDarkSquareStyle: {
|
|
14
|
-
backgroundColor: string;
|
|
15
|
-
};
|
|
16
|
-
customLightSquareStyle: {
|
|
17
|
-
backgroundColor: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export type AnalysisModalStyles = {
|
|
21
|
-
panel: CSSProperties;
|
|
22
|
-
title: CSSProperties;
|
|
23
|
-
closeButton: CSSProperties;
|
|
24
|
-
};
|
|
25
|
-
export declare const getAnalysisModalStyles: (theme: "light" | "dark") => AnalysisModalStyles;
|
|
26
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Square overlay colors for puzzle + analysis boards.
|
|
3
|
-
* Tweak values here when iterating on highlights.
|
|
4
|
-
*/
|
|
5
|
-
export declare const squareHighlightColors: {
|
|
6
|
-
/** King in check */
|
|
7
|
-
readonly check: "#e53935";
|
|
8
|
-
/** Hint square (puzzle) */
|
|
9
|
-
readonly hint: "rgba(119, 177, 212, 0.75)";
|
|
10
|
-
/** Wrong guess square (puzzle) */
|
|
11
|
-
readonly incorrect: "rgba(255, 127, 127, 0.8)";
|
|
12
|
-
/** Last move from/to (analysis replay) */
|
|
13
|
-
readonly lastMove: {
|
|
14
|
-
readonly light: "rgba(253, 216, 53, 0.55)";
|
|
15
|
-
readonly dark: "rgba(144, 202, 249, 0.5)";
|
|
16
|
-
};
|
|
17
|
-
/** DefaultAnalysisSidebar selected move chip */
|
|
18
|
-
readonly sidebarActiveMove: {
|
|
19
|
-
readonly light: "rgba(119, 177, 212, 1)";
|
|
20
|
-
readonly dark: "rgba(90, 159, 190, 1)";
|
|
21
|
-
};
|
|
22
|
-
readonly sidebarMove: {
|
|
23
|
-
readonly light: "rgba(240, 240, 240, 1)";
|
|
24
|
-
readonly dark: "rgba(45, 45, 45, 1)";
|
|
25
|
-
};
|
|
26
|
-
/** Analysis sidebar: Start row */
|
|
27
|
-
readonly sidebarStart: {
|
|
28
|
-
readonly light: "#e8e8e8";
|
|
29
|
-
readonly dark: "#262626";
|
|
30
|
-
};
|
|
31
|
-
/** Alternating main-line move rows (index 0 = darker, 1 = lighter). */
|
|
32
|
-
readonly sidebarMainStripe: readonly [{
|
|
33
|
-
readonly light: "#c9c9c9";
|
|
34
|
-
readonly dark: "#1c1c1c";
|
|
35
|
-
}, {
|
|
36
|
-
readonly light: "#f2f2f2";
|
|
37
|
-
readonly dark: "#383838";
|
|
38
|
-
}];
|
|
39
|
-
/** Alternating user-variation rows (index 0 = slightly tinted, 1 = lighter). */
|
|
40
|
-
readonly sidebarVariationStripe: readonly [{
|
|
41
|
-
readonly light: "#eef5fb";
|
|
42
|
-
readonly dark: "#2c3540";
|
|
43
|
-
}, {
|
|
44
|
-
readonly light: "#f7fbfe";
|
|
45
|
-
readonly dark: "#343f4c";
|
|
46
|
-
}];
|
|
47
|
-
};
|
|
48
|
-
export declare const getLastMoveSquareStyles: (from: string, to: string, theme: "light" | "dark") => Record<string, {
|
|
49
|
-
backgroundColor: string;
|
|
50
|
-
}>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { AnalysisBoard } from '../features/analysis/defaults/AnalysisBoard';
|
|
3
|
-
declare const meta: Meta<typeof AnalysisBoard>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof AnalysisBoard>;
|
|
6
|
-
export declare const Default: Story;
|
|
7
|
-
export declare const LightTheme: Story;
|
|
8
|
-
/** Requires `npm run copy:stockfish` so WASM is served from `public/stockfish/`. */
|
|
9
|
-
export declare const WithStockfishEngine: Story;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { HighlightChessboard } from 'react-chess-core';
|
|
3
|
-
declare const meta: Meta<typeof HighlightChessboard>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof HighlightChessboard>;
|
|
6
|
-
export declare const Default: Story;
|
|
7
|
-
export declare const KingInCheck: Story;
|
|
8
|
-
export declare const WithHint: Story;
|
|
9
|
-
export declare const IncorrectMove: Story;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const samplePuzzleFen = "r6k/pp2r2p/4Rp1Q/3p4/8/1N1P2R1/PqP2bPP/7K b - - 0 24";
|
|
2
|
-
export declare const samplePuzzleMoves: string[];
|
|
3
|
-
/** Completed puzzle snapshot for analysis stories. */
|
|
4
|
-
export declare const createSampleAnalysisContext: () => import("../features/analysis/core/analysisContext").PuzzleAnalysisContext;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { AnalysisBoard } from '../../features/analysis/defaults/AnalysisBoard';
|
|
3
|
-
declare const meta: Meta<typeof AnalysisBoard>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof AnalysisBoard>;
|
|
6
|
-
/** Puzzle 66abad1bcb8d6163fd6e172a — rapid clicks through every main-line move. */
|
|
7
|
-
export declare const Move3Ke6DuringAnalysis: Story;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { PuzzleRegression } from './fixtures';
|
|
2
|
-
/** Main-line sidebar labels (`Start`, `1. e4`, …) for a regression puzzle. */
|
|
3
|
-
export declare const getRegressionMainLineLabels: (regression: PuzzleRegression) => string[];
|
|
4
|
-
/** Completed puzzle snapshot for analysis regression stories. */
|
|
5
|
-
export declare const createRegressionAnalysisContext: (regression: PuzzleRegression) => import("../../features/analysis/core/analysisContext").PuzzleAnalysisContext;
|