react-native-chess-kit 0.4.2 → 0.5.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.
Files changed (82) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +168 -168
  3. package/lib/commonjs/board-annotations.js +8 -8
  4. package/lib/commonjs/board-arrows.js +7 -7
  5. package/lib/commonjs/board-background.js +5 -5
  6. package/lib/commonjs/board-coordinates.js +78 -11
  7. package/lib/commonjs/board-coordinates.js.map +1 -1
  8. package/lib/commonjs/board-drag-ghost.js +10 -10
  9. package/lib/commonjs/board-highlights.js +15 -15
  10. package/lib/commonjs/board-legal-dots.js +5 -5
  11. package/lib/commonjs/board-piece.js +25 -25
  12. package/lib/commonjs/board-pieces.js +6 -6
  13. package/lib/commonjs/board.js +76 -35
  14. package/lib/commonjs/board.js.map +1 -1
  15. package/lib/commonjs/constants.js +4 -1
  16. package/lib/commonjs/constants.js.map +1 -1
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/promotion-picker.js +8 -8
  19. package/lib/commonjs/static-board.js +51 -16
  20. package/lib/commonjs/static-board.js.map +1 -1
  21. package/lib/commonjs/use-board-gesture.js +52 -33
  22. package/lib/commonjs/use-board-gesture.js.map +1 -1
  23. package/lib/commonjs/use-board-pieces.js +15 -15
  24. package/lib/commonjs/use-board-state.js +8 -8
  25. package/lib/commonjs/use-premove.js +12 -12
  26. package/lib/module/board-annotations.js +8 -8
  27. package/lib/module/board-arrows.js +7 -7
  28. package/lib/module/board-background.js +5 -5
  29. package/lib/module/board-coordinates.js +79 -12
  30. package/lib/module/board-coordinates.js.map +1 -1
  31. package/lib/module/board-drag-ghost.js +10 -10
  32. package/lib/module/board-highlights.js +15 -15
  33. package/lib/module/board-legal-dots.js +5 -5
  34. package/lib/module/board-piece.js +25 -25
  35. package/lib/module/board-pieces.js +6 -6
  36. package/lib/module/board.js +77 -36
  37. package/lib/module/board.js.map +1 -1
  38. package/lib/module/constants.js +3 -0
  39. package/lib/module/constants.js.map +1 -1
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/module/promotion-picker.js +8 -8
  42. package/lib/module/static-board.js +52 -17
  43. package/lib/module/static-board.js.map +1 -1
  44. package/lib/module/use-board-gesture.js +52 -33
  45. package/lib/module/use-board-gesture.js.map +1 -1
  46. package/lib/module/use-board-pieces.js +15 -15
  47. package/lib/module/use-board-state.js +8 -8
  48. package/lib/module/use-premove.js +12 -12
  49. package/lib/typescript/board-coordinates.d.ts +10 -4
  50. package/lib/typescript/board-coordinates.d.ts.map +1 -1
  51. package/lib/typescript/board.d.ts.map +1 -1
  52. package/lib/typescript/constants.d.ts +2 -0
  53. package/lib/typescript/constants.d.ts.map +1 -1
  54. package/lib/typescript/index.d.ts +1 -1
  55. package/lib/typescript/index.d.ts.map +1 -1
  56. package/lib/typescript/static-board.d.ts.map +1 -1
  57. package/lib/typescript/types.d.ts +23 -3
  58. package/lib/typescript/types.d.ts.map +1 -1
  59. package/lib/typescript/use-board-gesture.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/src/board-annotations.tsx +147 -147
  62. package/src/board-arrows.tsx +197 -197
  63. package/src/board-background.tsx +46 -46
  64. package/src/board-coordinates.tsx +192 -98
  65. package/src/board-drag-ghost.tsx +132 -132
  66. package/src/board-highlights.tsx +226 -226
  67. package/src/board-legal-dots.tsx +73 -73
  68. package/src/board-piece.tsx +160 -160
  69. package/src/board-pieces.tsx +63 -63
  70. package/src/board.tsx +685 -641
  71. package/src/constants.ts +103 -100
  72. package/src/index.ts +101 -100
  73. package/src/pieces/default-pieces.tsx +383 -383
  74. package/src/pieces/index.ts +1 -1
  75. package/src/promotion-picker.tsx +147 -147
  76. package/src/static-board.tsx +187 -150
  77. package/src/themes.ts +129 -129
  78. package/src/types.ts +373 -352
  79. package/src/use-board-gesture.ts +429 -412
  80. package/src/use-board-pieces.ts +158 -158
  81. package/src/use-board-state.ts +111 -111
  82. package/src/use-premove.ts +59 -59
package/src/constants.ts CHANGED
@@ -1,100 +1,103 @@
1
- import type { BoardColors } from './types';
2
-
3
- // ---------------------------------------------------------------------------
4
- // Default colors
5
- // ---------------------------------------------------------------------------
6
-
7
- /** Default board colors (chess.com green) */
8
- export const DEFAULT_BOARD_COLORS: BoardColors = {
9
- light: '#eeeed2',
10
- dark: '#769656',
11
- };
12
-
13
- /** Default last-move highlight color */
14
- export const DEFAULT_LAST_MOVE_COLOR = 'rgba(255, 255, 0, 0.4)';
15
-
16
- /** Default check highlight color (red radial feel) */
17
- export const DEFAULT_CHECK_COLOR = 'rgba(235, 97, 80, 0.8)';
18
-
19
- /** Default selected piece square color */
20
- export const DEFAULT_SELECTED_COLOR = 'rgba(20, 85, 200, 0.5)';
21
-
22
- /** Default premove highlight color */
23
- export const DEFAULT_PREMOVE_COLOR = 'rgba(20, 85, 200, 0.3)';
24
-
25
- /** Default drag target highlight color */
26
- export const DEFAULT_DRAG_TARGET_COLOR = 'rgba(0, 0, 0, 0.1)';
27
-
28
- /** Default arrow color */
29
- export const DEFAULT_ARROW_COLOR = 'rgba(243, 166, 50, 0.85)';
30
-
31
- /** Default shape (circle) color */
32
- export const DEFAULT_SHAPE_COLOR = 'rgba(21, 120, 27, 0.7)';
33
-
34
- /** Default annotation background color */
35
- export const DEFAULT_ANNOTATION_BG = 'rgba(235, 97, 80, 0.9)';
36
-
37
- /** Default annotation text color */
38
- export const DEFAULT_ANNOTATION_TEXT = '#ffffff';
39
-
40
- // ---------------------------------------------------------------------------
41
- // Animation defaults
42
- // ---------------------------------------------------------------------------
43
-
44
- /** Default move animation duration in ms */
45
- export const DEFAULT_MOVE_DURATION = 200;
46
-
47
- /** Duration for capture fade-out animation in ms */
48
- export const CAPTURE_FADE_DURATION = 150;
49
-
50
- // ---------------------------------------------------------------------------
51
- // Layout constants
52
- // ---------------------------------------------------------------------------
53
-
54
- /** Legal move dot size as fraction of square size */
55
- export const DOT_SCALE = 0.28;
56
-
57
- /** Legal move capture ring size as fraction of square size */
58
- export const RING_SCALE = 0.85;
59
-
60
- /** Legal move capture ring border as fraction of square size */
61
- export const RING_BORDER_RATIO = 0.08;
62
-
63
- /** Arrow stroke width as fraction of square size (percentage-based viewBox) */
64
- export const ARROW_STROKE_WIDTH = 2.5;
65
-
66
- /** Arrow head size */
67
- export const ARROW_HEAD_SIZE = 2.5;
68
-
69
- /** Arrow shorten amount (to avoid overlapping squares) */
70
- export const ARROW_SHORTEN_BY = 4;
71
-
72
- /** Annotation badge size as fraction of square size */
73
- export const ANNOTATION_SCALE = 0.35;
74
-
75
- /** Coordinate font size as fraction of square size */
76
- export const COORDINATE_FONT_SCALE = 0.22;
77
-
78
- /** Drag ghost scale factor (1.1x larger than normal piece) */
79
- export const DRAG_GHOST_SCALE = 1.1;
80
-
81
- /** Promotion picker piece padding as fraction of square size */
82
- export const PROMOTION_PIECE_PADDING = 0.1;
83
-
84
- // ---------------------------------------------------------------------------
85
- // Piece codes (pre-computed to avoid allocation)
86
- // ---------------------------------------------------------------------------
87
-
88
- export const PIECE_CODES = [
89
- 'wp', 'wn', 'wb', 'wr', 'wq', 'wk',
90
- 'bp', 'bn', 'bb', 'br', 'bq', 'bk',
91
- ] as const;
92
-
93
- /** Board square indices 0-63 (pre-computed) */
94
- export const SQUARE_INDICES = Array.from({ length: 64 }, (_, i) => i);
95
-
96
- /** File letters in order */
97
- export const FILES_WHITE = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] as const;
98
- export const FILES_BLACK = ['h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'] as const;
99
- export const RANKS_WHITE = ['8', '7', '6', '5', '4', '3', '2', '1'] as const;
100
- export const RANKS_BLACK = ['1', '2', '3', '4', '5', '6', '7', '8'] as const;
1
+ import type { BoardColors } from './types';
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // Default colors
5
+ // ---------------------------------------------------------------------------
6
+
7
+ /** Default board colors (chess.com green) */
8
+ export const DEFAULT_BOARD_COLORS: BoardColors = {
9
+ light: '#eeeed2',
10
+ dark: '#769656',
11
+ };
12
+
13
+ /** Default last-move highlight color */
14
+ export const DEFAULT_LAST_MOVE_COLOR = 'rgba(255, 255, 0, 0.4)';
15
+
16
+ /** Default check highlight color (red radial feel) */
17
+ export const DEFAULT_CHECK_COLOR = 'rgba(235, 97, 80, 0.8)';
18
+
19
+ /** Default selected piece square color */
20
+ export const DEFAULT_SELECTED_COLOR = 'rgba(20, 85, 200, 0.5)';
21
+
22
+ /** Default premove highlight color */
23
+ export const DEFAULT_PREMOVE_COLOR = 'rgba(20, 85, 200, 0.3)';
24
+
25
+ /** Default drag target highlight color */
26
+ export const DEFAULT_DRAG_TARGET_COLOR = 'rgba(0, 0, 0, 0.1)';
27
+
28
+ /** Default arrow color */
29
+ export const DEFAULT_ARROW_COLOR = 'rgba(243, 166, 50, 0.85)';
30
+
31
+ /** Default shape (circle) color */
32
+ export const DEFAULT_SHAPE_COLOR = 'rgba(21, 120, 27, 0.7)';
33
+
34
+ /** Default annotation background color */
35
+ export const DEFAULT_ANNOTATION_BG = 'rgba(235, 97, 80, 0.9)';
36
+
37
+ /** Default annotation text color */
38
+ export const DEFAULT_ANNOTATION_TEXT = '#ffffff';
39
+
40
+ // ---------------------------------------------------------------------------
41
+ // Animation defaults
42
+ // ---------------------------------------------------------------------------
43
+
44
+ /** Default move animation duration in ms */
45
+ export const DEFAULT_MOVE_DURATION = 200;
46
+
47
+ /** Duration for capture fade-out animation in ms */
48
+ export const CAPTURE_FADE_DURATION = 150;
49
+
50
+ // ---------------------------------------------------------------------------
51
+ // Layout constants
52
+ // ---------------------------------------------------------------------------
53
+
54
+ /** Legal move dot size as fraction of square size */
55
+ export const DOT_SCALE = 0.28;
56
+
57
+ /** Legal move capture ring size as fraction of square size */
58
+ export const RING_SCALE = 0.85;
59
+
60
+ /** Legal move capture ring border as fraction of square size */
61
+ export const RING_BORDER_RATIO = 0.08;
62
+
63
+ /** Arrow stroke width as fraction of square size (percentage-based viewBox) */
64
+ export const ARROW_STROKE_WIDTH = 2.5;
65
+
66
+ /** Arrow head size */
67
+ export const ARROW_HEAD_SIZE = 2.5;
68
+
69
+ /** Arrow shorten amount (to avoid overlapping squares) */
70
+ export const ARROW_SHORTEN_BY = 4;
71
+
72
+ /** Annotation badge size as fraction of square size */
73
+ export const ANNOTATION_SCALE = 0.35;
74
+
75
+ /** Coordinate font size as fraction of square size */
76
+ export const COORDINATE_FONT_SCALE = 0.22;
77
+
78
+ /** Outside-coordinate gutter width as fraction of square size */
79
+ export const COORDINATE_GUTTER_SCALE = 0.45;
80
+
81
+ /** Drag ghost scale factor (1.1x larger than normal piece) */
82
+ export const DRAG_GHOST_SCALE = 1.1;
83
+
84
+ /** Promotion picker piece padding as fraction of square size */
85
+ export const PROMOTION_PIECE_PADDING = 0.1;
86
+
87
+ // ---------------------------------------------------------------------------
88
+ // Piece codes (pre-computed to avoid allocation)
89
+ // ---------------------------------------------------------------------------
90
+
91
+ export const PIECE_CODES = [
92
+ 'wp', 'wn', 'wb', 'wr', 'wq', 'wk',
93
+ 'bp', 'bn', 'bb', 'br', 'bq', 'bk',
94
+ ] as const;
95
+
96
+ /** Board square indices 0-63 (pre-computed) */
97
+ export const SQUARE_INDICES = Array.from({ length: 64 }, (_, i) => i);
98
+
99
+ /** File letters in order */
100
+ export const FILES_WHITE = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] as const;
101
+ export const FILES_BLACK = ['h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'] as const;
102
+ export const RANKS_WHITE = ['8', '7', '6', '5', '4', '3', '2', '1'] as const;
103
+ export const RANKS_BLACK = ['1', '2', '3', '4', '5', '6', '7', '8'] as const;
package/src/index.ts CHANGED
@@ -1,100 +1,101 @@
1
- // react-native-chess-kit
2
- // High-performance chess board for React Native
3
-
4
- // ---------------------------------------------------------------------------
5
- // Main components
6
- // ---------------------------------------------------------------------------
7
-
8
- export { Board } from './board';
9
- export { StaticBoard } from './static-board';
10
-
11
- // ---------------------------------------------------------------------------
12
- // Overlay primitives (for advanced consumers building custom layers)
13
- // ---------------------------------------------------------------------------
14
-
15
- export { SquareHighlight } from './board-highlights';
16
- export { Arrow } from './board-arrows';
17
- export { Annotation } from './board-annotations';
18
- export { PromotionPicker } from './promotion-picker';
19
-
20
- // ---------------------------------------------------------------------------
21
- // Default piece set
22
- // ---------------------------------------------------------------------------
23
-
24
- export { DefaultPieceSet } from './pieces';
25
-
26
- // ---------------------------------------------------------------------------
27
- // Themes
28
- // ---------------------------------------------------------------------------
29
-
30
- export { BOARD_THEMES, BOARD_COLORS } from './themes';
31
-
32
- // ---------------------------------------------------------------------------
33
- // Constants (useful for custom overlays matching library defaults)
34
- // ---------------------------------------------------------------------------
35
-
36
- export {
37
- DEFAULT_BOARD_COLORS,
38
- DEFAULT_LAST_MOVE_COLOR,
39
- DEFAULT_CHECK_COLOR,
40
- DEFAULT_SELECTED_COLOR,
41
- DEFAULT_PREMOVE_COLOR,
42
- DEFAULT_DRAG_TARGET_COLOR,
43
- DEFAULT_ARROW_COLOR,
44
- DEFAULT_SHAPE_COLOR,
45
- DEFAULT_ANNOTATION_BG,
46
- DEFAULT_ANNOTATION_TEXT,
47
- DEFAULT_MOVE_DURATION,
48
- CAPTURE_FADE_DURATION,
49
- } from './constants';
50
-
51
- // ---------------------------------------------------------------------------
52
- // Types
53
- // ---------------------------------------------------------------------------
54
-
55
- export type {
56
- // Core chess types
57
- ChessColor,
58
- MoveMethod,
59
- PromotionPiece,
60
- HapticType,
61
- PieceCode,
62
-
63
- // Board component API
64
- BoardRef,
65
- BoardProps,
66
- BoardColors,
67
- StaticBoardProps,
68
-
69
- // Piece data (useful for custom piece renderers)
70
- BoardPiece,
71
- ParsedPiece,
72
- PieceSetMap,
73
-
74
- // Overlay data types
75
- HighlightData,
76
- ArrowData,
77
- ShapeData,
78
- AnnotationData,
79
- PremoveData,
80
-
81
- // Animation config
82
- AnimationConfig,
83
- TimingAnimationConfig,
84
- SpringAnimationConfig,
85
-
86
- // Board theme
87
- BoardTheme,
88
-
89
- // Gesture state (useful for advanced overlays)
90
- GestureState,
91
-
92
- // Legal move dots (useful if building custom dot rendering)
93
- LegalMoveTarget,
94
- } from './types';
95
-
96
- // ---------------------------------------------------------------------------
97
- // Utility functions (useful for overlay positioning)
98
- // ---------------------------------------------------------------------------
99
-
100
- export { squareToXY, xyToSquare } from './use-board-pieces';
1
+ // react-native-chess-kit
2
+ // High-performance chess board for React Native
3
+
4
+ // ---------------------------------------------------------------------------
5
+ // Main components
6
+ // ---------------------------------------------------------------------------
7
+
8
+ export { Board } from './board';
9
+ export { StaticBoard } from './static-board';
10
+
11
+ // ---------------------------------------------------------------------------
12
+ // Overlay primitives (for advanced consumers building custom layers)
13
+ // ---------------------------------------------------------------------------
14
+
15
+ export { SquareHighlight } from './board-highlights';
16
+ export { Arrow } from './board-arrows';
17
+ export { Annotation } from './board-annotations';
18
+ export { PromotionPicker } from './promotion-picker';
19
+
20
+ // ---------------------------------------------------------------------------
21
+ // Default piece set
22
+ // ---------------------------------------------------------------------------
23
+
24
+ export { DefaultPieceSet } from './pieces';
25
+
26
+ // ---------------------------------------------------------------------------
27
+ // Themes
28
+ // ---------------------------------------------------------------------------
29
+
30
+ export { BOARD_THEMES, BOARD_COLORS } from './themes';
31
+
32
+ // ---------------------------------------------------------------------------
33
+ // Constants (useful for custom overlays matching library defaults)
34
+ // ---------------------------------------------------------------------------
35
+
36
+ export {
37
+ DEFAULT_BOARD_COLORS,
38
+ DEFAULT_LAST_MOVE_COLOR,
39
+ DEFAULT_CHECK_COLOR,
40
+ DEFAULT_SELECTED_COLOR,
41
+ DEFAULT_PREMOVE_COLOR,
42
+ DEFAULT_DRAG_TARGET_COLOR,
43
+ DEFAULT_ARROW_COLOR,
44
+ DEFAULT_SHAPE_COLOR,
45
+ DEFAULT_ANNOTATION_BG,
46
+ DEFAULT_ANNOTATION_TEXT,
47
+ DEFAULT_MOVE_DURATION,
48
+ CAPTURE_FADE_DURATION,
49
+ } from './constants';
50
+
51
+ // ---------------------------------------------------------------------------
52
+ // Types
53
+ // ---------------------------------------------------------------------------
54
+
55
+ export type {
56
+ // Core chess types
57
+ ChessColor,
58
+ MoveMethod,
59
+ PromotionPiece,
60
+ HapticType,
61
+ PieceCode,
62
+
63
+ // Board component API
64
+ BoardRef,
65
+ BoardProps,
66
+ BoardColors,
67
+ StaticBoardProps,
68
+ CoordinatePosition,
69
+
70
+ // Piece data (useful for custom piece renderers)
71
+ BoardPiece,
72
+ ParsedPiece,
73
+ PieceSetMap,
74
+
75
+ // Overlay data types
76
+ HighlightData,
77
+ ArrowData,
78
+ ShapeData,
79
+ AnnotationData,
80
+ PremoveData,
81
+
82
+ // Animation config
83
+ AnimationConfig,
84
+ TimingAnimationConfig,
85
+ SpringAnimationConfig,
86
+
87
+ // Board theme
88
+ BoardTheme,
89
+
90
+ // Gesture state (useful for advanced overlays)
91
+ GestureState,
92
+
93
+ // Legal move dots (useful if building custom dot rendering)
94
+ LegalMoveTarget,
95
+ } from './types';
96
+
97
+ // ---------------------------------------------------------------------------
98
+ // Utility functions (useful for overlay positioning)
99
+ // ---------------------------------------------------------------------------
100
+
101
+ export { squareToXY, xyToSquare } from './use-board-pieces';