react-chess-puzzle-kit 1.0.0

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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +331 -0
  3. package/dist/features/analysis/AnalysisBoard.d.ts +18 -0
  4. package/dist/features/analysis/AnalysisBoardCore.d.ts +28 -0
  5. package/dist/features/analysis/AnalysisBoardLayout.d.ts +12 -0
  6. package/dist/features/analysis/AnalysisChessboardView.d.ts +5 -0
  7. package/dist/features/analysis/AnalysisPosition.d.ts +53 -0
  8. package/dist/features/analysis/AnalysisTrigger.d.ts +6 -0
  9. package/dist/features/analysis/DefaultAnalysisContainer.d.ts +3 -0
  10. package/dist/features/analysis/DefaultAnalysisSidebar.d.ts +2 -0
  11. package/dist/features/analysis/analysisBoardHighlightColors.d.ts +12 -0
  12. package/dist/features/analysis/analysisContext.d.ts +8 -0
  13. package/dist/features/analysis/analysisLayout.d.ts +5 -0
  14. package/dist/features/analysis/core/AnalysisBoardCore.d.ts +28 -0
  15. package/dist/features/analysis/core/AnalysisChessboardView.d.ts +5 -0
  16. package/dist/features/analysis/core/AnalysisErrorBoundary.d.ts +14 -0
  17. package/dist/features/analysis/core/AnalysisPosition.d.ts +54 -0
  18. package/dist/features/analysis/core/analysisContext.d.ts +13 -0
  19. package/dist/features/analysis/core/analysisLayout.d.ts +5 -0
  20. package/dist/features/analysis/core/analysisLayoutConfig.d.ts +6 -0
  21. package/dist/features/analysis/core/index.d.ts +9 -0
  22. package/dist/features/analysis/core/renderProps.d.ts +39 -0
  23. package/dist/features/analysis/core/useAnalysisBoardModel.d.ts +36 -0
  24. package/dist/features/analysis/core/usePuzzleAnalysis.d.ts +10 -0
  25. package/dist/features/analysis/defaults/AnalysisBoard.d.ts +16 -0
  26. package/dist/features/analysis/defaults/AnalysisBoardLayout.d.ts +14 -0
  27. package/dist/features/analysis/defaults/DefaultAnalysisContainer.d.ts +4 -0
  28. package/dist/features/analysis/defaults/DefaultAnalysisSidebar.d.ts +3 -0
  29. package/dist/features/analysis/defaults/analysisLayout.d.ts +3 -0
  30. package/dist/features/analysis/defaults/analysisModalStyles.d.ts +7 -0
  31. package/dist/features/analysis/defaults/analysisSidebarColors.d.ts +37 -0
  32. package/dist/features/analysis/defaults/analysisSidebarRowStyle.d.ts +8 -0
  33. package/dist/features/analysis/defaults/index.d.ts +8 -0
  34. package/dist/features/analysis/index.d.ts +3 -0
  35. package/dist/features/analysis/renderProps.d.ts +39 -0
  36. package/dist/features/analysis/useAnalysisBoardModel.d.ts +33 -0
  37. package/dist/features/analysis/usePuzzleAnalysis.d.ts +10 -0
  38. package/dist/features/board/BlankPuzzleBoard.d.ts +5 -0
  39. package/dist/features/board/HighlightChessboard.d.ts +2 -0
  40. package/dist/features/board/LineBoard.d.ts +15 -0
  41. package/dist/features/board/LineBoardWithControls.d.ts +50 -0
  42. package/dist/features/board/PuzzleBoard.d.ts +10 -0
  43. package/dist/features/board/PuzzleBoardWithControls.d.ts +51 -0
  44. package/dist/features/board/PuzzlePlaySurface.d.ts +25 -0
  45. package/dist/features/board/boardSquareHighlightColors.d.ts +1 -0
  46. package/dist/features/board/chessboardTheme.d.ts +2 -0
  47. package/dist/features/board/defaults/DefaultLineControls.d.ts +5 -0
  48. package/dist/features/board/defaults/DefaultPuzzleControls.d.ts +18 -0
  49. package/dist/features/board/defaults/index.d.ts +1 -0
  50. package/dist/features/board/puzzleBoardLayout.d.ts +8 -0
  51. package/dist/features/engine/EngineEvaluationPanel.d.ts +8 -0
  52. package/dist/features/engine/StockfishBrowserEngine.d.ts +1 -0
  53. package/dist/features/engine/formatEvaluation.d.ts +1 -0
  54. package/dist/features/engine/index.d.ts +1 -0
  55. package/dist/features/engine/isAnalyzableFen.d.ts +1 -0
  56. package/dist/features/engine/parseUciInfo.d.ts +1 -0
  57. package/dist/features/engine/stockfishUrls.d.ts +1 -0
  58. package/dist/features/engine/types.d.ts +1 -0
  59. package/dist/features/engine/useAnalysisEngine.d.ts +1 -0
  60. package/dist/features/position/Position.d.ts +67 -0
  61. package/dist/features/position/Position.test.d.ts +1 -0
  62. package/dist/features/position/Traversable.d.ts +4 -0
  63. package/dist/features/position/moveHistory.d.ts +7 -0
  64. package/dist/features/theme/ThemeContext.d.ts +26 -0
  65. package/dist/features/theme/ThemeProvider.d.ts +7 -0
  66. package/dist/features/theme/squareHighlightColors.d.ts +50 -0
  67. package/dist/index.d.ts +26 -0
  68. package/dist/index.esm.js +861 -0
  69. package/dist/index.js +885 -0
  70. package/dist/stories/AnalysisBoard.stories.d.ts +9 -0
  71. package/dist/stories/HighlightChessboard.stories.d.ts +9 -0
  72. package/dist/stories/PuzzleBoard.stories.d.ts +6 -0
  73. package/dist/stories/PuzzleBoardWithControls.stories.d.ts +9 -0
  74. package/dist/stories/analysisFixtures.d.ts +4 -0
  75. package/dist/stories/regressions/PuzzleRegressions.stories.d.ts +7 -0
  76. package/dist/stories/regressions/StockfishAnalysisRegressions.stories.d.ts +7 -0
  77. package/dist/stories/regressions/fixtures.d.ts +18 -0
  78. package/dist/stories/regressions/regressionAnalysisContext.d.ts +5 -0
  79. package/dist/stories/storybookLayout.d.ts +4 -0
  80. package/dist/stories/withChessboardDnD.d.ts +4 -0
  81. package/dist/stories/withDefaultPuzzleControls.d.ts +7 -0
  82. package/dist/stories/withThemeProvider.d.ts +3 -0
  83. package/package.json +87 -0
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { PuzzleBoard } from '../features/board/PuzzleBoard';
3
+ declare const meta: Meta<typeof PuzzleBoard>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof PuzzleBoard>;
6
+ export declare const Default: Story;
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { PuzzleBoardWithControls } from '../features/board/PuzzleBoardWithControls';
3
+ declare const meta: Meta<typeof PuzzleBoardWithControls>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof PuzzleBoardWithControls>;
6
+ export declare const Default: Story;
7
+ export declare const MultiplePuzzles: Story;
8
+ /** Default controls + default analysis modal, sidebar, and engine panel. */
9
+ export declare const AllLibraryDefaults: Story;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,7 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { PuzzleBoardWithControls, PuzzleBoardWithControlsProps } from '../../features/board/PuzzleBoardWithControls';
3
+ declare const meta: Meta<typeof PuzzleBoardWithControls>;
4
+ export default meta;
5
+ export declare const WrongLegalCaptureShouldFail: import("@storybook/csf").StoryAnnotations<import("@storybook/react").ReactRenderer, PuzzleBoardWithControlsProps>;
6
+ export declare const DualCheckmateAccepted: import("@storybook/csf").StoryAnnotations<import("@storybook/react").ReactRenderer, PuzzleBoardWithControlsProps>;
7
+ export declare const WrongCaptureWhileInCheckShouldFail: import("@storybook/csf").StoryAnnotations<import("@storybook/react").ReactRenderer, PuzzleBoardWithControlsProps>;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,18 @@
1
+ export interface PuzzleRegression {
2
+ /** Story name shown in Storybook. */
3
+ name: string;
4
+ /** The edge case and the expected behavior, for the story docs. */
5
+ description: string;
6
+ /** Source puzzle id (endchess) for traceability. */
7
+ sourceId: string;
8
+ /** Starting FEN as stored for the puzzle. */
9
+ fen: string;
10
+ /** Space-separated UCI solution moves (first move is played automatically). */
11
+ moves: string;
12
+ }
13
+ /**
14
+ * Real puzzles that previously exposed bugs, captured so the scenarios can be
15
+ * reproduced in Storybook. Add an entry here and a matching story export in
16
+ * `PuzzleRegressions.stories.tsx`.
17
+ */
18
+ export declare const PUZZLE_REGRESSIONS: Record<string, PuzzleRegression>;
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,4 @@
1
+ import { AnalysisLayoutConfig } from 'react-chess-core';
2
+ /** Smaller boards for Storybook previews (production defaults stay at 480+). */
3
+ export declare const STORYBOOK_BOARD_WIDTH = 360;
4
+ export declare const STORYBOOK_ANALYSIS_LAYOUT: AnalysisLayoutConfig;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ /** Required by react-chessboard when rendering squares outside PuzzleBoard / AnalysisChessboardView. */
3
+ declare const withChessboardDnD: (Story: React.ComponentType) => React.JSX.Element;
4
+ export default withChessboardDnD;
@@ -0,0 +1,7 @@
1
+ import { Decorator } from '@storybook/react';
2
+ /**
3
+ * Supplies {@link defaultRenderControls} when a story omits `renderControls`.
4
+ * Use on `PuzzleBoardWithControls` stories for the library default button row.
5
+ */
6
+ export declare const withDefaultPuzzleControls: Decorator;
7
+ export default withDefaultPuzzleControls;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const withThemeProvider: (Story: React.ComponentType, context: any) => React.JSX.Element;
3
+ export default withThemeProvider;
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "react-chess-puzzle-kit",
3
+ "version": "1.0.0",
4
+ "description": "React chess puzzle kit: play, controls, analysis, and browser Stockfish for endchess.training and other apps",
5
+ "license": "MIT",
6
+ "author": "Robert Blackwell",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.esm.js",
9
+ "types": "dist/index.d.ts",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/reblackwell3/react-chess-puzzle-kit.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/reblackwell3/react-chess-puzzle-kit/issues"
16
+ },
17
+ "homepage": "https://github.com/reblackwell3/react-chess-puzzle-kit#readme",
18
+ "keywords": [
19
+ "react",
20
+ "chess",
21
+ "chess.js",
22
+ "chess puzzle",
23
+ "puzzle",
24
+ "analysis",
25
+ "stockfish",
26
+ "react-chessboard",
27
+ "chessboard",
28
+ "drag and drop"
29
+ ],
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "scripts": {
34
+ "build": "rollup -c",
35
+ "copy:stockfish": "node scripts/copy-stockfish.mjs",
36
+ "prepare": "rollup -c",
37
+ "prestorybook": "npm run copy:stockfish",
38
+ "test": "jest --config jest.config.cjs",
39
+ "storybook": "storybook dev -p 6006",
40
+ "build-storybook": "storybook build",
41
+ "serve-storybook": "serve storybook-static",
42
+ "prepublishOnly": "npm run build"
43
+ },
44
+ "dependencies": {
45
+ "chess.js": "^1.0.0-beta.8",
46
+ "rollup": "^4.22.2",
47
+ "rollup-plugin-peer-deps-external": "^2.2.4",
48
+ "rollup-plugin-typescript2": "^0.36.0",
49
+ "typescript": "^5.6.2"
50
+ },
51
+ "peerDependencies": {
52
+ "chess.js": "^1.0.0-beta.8",
53
+ "react": "^18.3.1",
54
+ "react-chess-core": "^0.1.0",
55
+ "react-chessboard": "^4.7.1"
56
+ },
57
+ "devDependencies": {
58
+ "@chromatic-com/storybook": "^1.9.0",
59
+ "@rollup/plugin-commonjs": "^26.0.1",
60
+ "@rollup/plugin-node-resolve": "^15.2.3",
61
+ "@rollup/plugin-terser": "^0.4.4",
62
+ "@storybook/addon-essentials": "^8.2.9",
63
+ "@storybook/addon-interactions": "^8.2.9",
64
+ "@storybook/addon-links": "^8.2.9",
65
+ "@storybook/addon-onboarding": "^8.2.9",
66
+ "@storybook/blocks": "^8.2.9",
67
+ "@storybook/preset-typescript": "^3.0.0",
68
+ "@storybook/react": "^8.2.9",
69
+ "@storybook/react-vite": "^8.2.9",
70
+ "@storybook/test": "^8.2.9",
71
+ "@types/jest": "^29.5.12",
72
+ "@types/react": "^18.3.12",
73
+ "@types/react-dom": "^18.3.1",
74
+ "chess.js": "^1.0.0-beta.8",
75
+ "jest": "^29.7.0",
76
+ "react": "^18.3.1",
77
+ "react-chess-core": "^0.1.0",
78
+ "react-chessboard": "^4.7.1",
79
+ "storybook": "^8.2.9",
80
+ "ts-jest": "^29.2.4",
81
+ "vite": "^5.4.11",
82
+ "vite-tsconfig-paths": "^5.0.1"
83
+ },
84
+ "optionalDependencies": {
85
+ "stockfish": "^18.0.7"
86
+ }
87
+ }