react-native-chess-kit 0.5.2 → 0.5.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.
Files changed (106) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +187 -168
  3. package/lib/commonjs/board-annotations.js +8 -8
  4. package/lib/commonjs/board-annotations.js.map +1 -1
  5. package/lib/commonjs/board-arrows.js.map +1 -1
  6. package/lib/commonjs/board-background.js +5 -5
  7. package/lib/commonjs/board-background.js.map +1 -1
  8. package/lib/commonjs/board-coordinates.js +8 -8
  9. package/lib/commonjs/board-coordinates.js.map +1 -1
  10. package/lib/commonjs/board-drag-ghost.js +10 -10
  11. package/lib/commonjs/board-drag-ghost.js.map +1 -1
  12. package/lib/commonjs/board-highlights.js +15 -15
  13. package/lib/commonjs/board-highlights.js.map +1 -1
  14. package/lib/commonjs/board-legal-dots.js +5 -5
  15. package/lib/commonjs/board-legal-dots.js.map +1 -1
  16. package/lib/commonjs/board-piece.js +25 -25
  17. package/lib/commonjs/board-piece.js.map +1 -1
  18. package/lib/commonjs/board-pieces.js +6 -6
  19. package/lib/commonjs/board-pieces.js.map +1 -1
  20. package/lib/commonjs/board.js +68 -63
  21. package/lib/commonjs/board.js.map +1 -1
  22. package/lib/commonjs/constants.js.map +1 -1
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/pieces/default-pieces.js.map +1 -1
  25. package/lib/commonjs/pieces/index.js.map +1 -1
  26. package/lib/commonjs/promotion-picker.js +9 -9
  27. package/lib/commonjs/promotion-picker.js.map +1 -1
  28. package/lib/commonjs/static-board.js +7 -7
  29. package/lib/commonjs/static-board.js.map +1 -1
  30. package/lib/commonjs/themes.js.map +1 -1
  31. package/lib/commonjs/types.js.map +1 -1
  32. package/lib/commonjs/use-board-gesture.js +26 -26
  33. package/lib/commonjs/use-board-gesture.js.map +1 -1
  34. package/lib/commonjs/use-board-pieces.js +15 -15
  35. package/lib/commonjs/use-board-pieces.js.map +1 -1
  36. package/lib/commonjs/use-board-state.js +21 -12
  37. package/lib/commonjs/use-board-state.js.map +1 -1
  38. package/lib/commonjs/use-premove.js +12 -12
  39. package/lib/commonjs/use-premove.js.map +1 -1
  40. package/lib/module/board-annotations.js +8 -8
  41. package/lib/module/board-annotations.js.map +1 -1
  42. package/lib/module/board-arrows.js.map +1 -1
  43. package/lib/module/board-background.js +5 -5
  44. package/lib/module/board-background.js.map +1 -1
  45. package/lib/module/board-coordinates.js +8 -8
  46. package/lib/module/board-coordinates.js.map +1 -1
  47. package/lib/module/board-drag-ghost.js +10 -10
  48. package/lib/module/board-drag-ghost.js.map +1 -1
  49. package/lib/module/board-highlights.js +15 -15
  50. package/lib/module/board-highlights.js.map +1 -1
  51. package/lib/module/board-legal-dots.js +5 -5
  52. package/lib/module/board-legal-dots.js.map +1 -1
  53. package/lib/module/board-piece.js +25 -25
  54. package/lib/module/board-piece.js.map +1 -1
  55. package/lib/module/board-pieces.js +6 -6
  56. package/lib/module/board-pieces.js.map +1 -1
  57. package/lib/module/board.js +68 -63
  58. package/lib/module/board.js.map +1 -1
  59. package/lib/module/constants.js.map +1 -1
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/pieces/default-pieces.js.map +1 -1
  62. package/lib/module/pieces/index.js.map +1 -1
  63. package/lib/module/promotion-picker.js +9 -9
  64. package/lib/module/promotion-picker.js.map +1 -1
  65. package/lib/module/static-board.js +7 -7
  66. package/lib/module/static-board.js.map +1 -1
  67. package/lib/module/themes.js.map +1 -1
  68. package/lib/module/types.js.map +1 -1
  69. package/lib/module/use-board-gesture.js +26 -26
  70. package/lib/module/use-board-gesture.js.map +1 -1
  71. package/lib/module/use-board-pieces.js +15 -15
  72. package/lib/module/use-board-pieces.js.map +1 -1
  73. package/lib/module/use-board-state.js +21 -12
  74. package/lib/module/use-board-state.js.map +1 -1
  75. package/lib/module/use-premove.js +12 -12
  76. package/lib/module/use-premove.js.map +1 -1
  77. package/lib/typescript/board-coordinates.d.ts.map +1 -1
  78. package/lib/typescript/board.d.ts.map +1 -1
  79. package/lib/typescript/promotion-picker.d.ts.map +1 -1
  80. package/lib/typescript/static-board.d.ts.map +1 -1
  81. package/lib/typescript/types.d.ts +12 -2
  82. package/lib/typescript/types.d.ts.map +1 -1
  83. package/lib/typescript/use-board-gesture.d.ts.map +1 -1
  84. package/lib/typescript/use-board-state.d.ts.map +1 -1
  85. package/package.json +23 -3
  86. package/src/board-annotations.tsx +147 -147
  87. package/src/board-background.tsx +46 -46
  88. package/src/board-coordinates.tsx +192 -192
  89. package/src/board-drag-ghost.tsx +132 -132
  90. package/src/board-highlights.tsx +226 -226
  91. package/src/board-legal-dots.tsx +73 -73
  92. package/src/board-piece.tsx +160 -160
  93. package/src/board-pieces.tsx +63 -63
  94. package/src/board.tsx +688 -685
  95. package/src/constants.ts +103 -103
  96. package/src/index.ts +101 -101
  97. package/src/pieces/default-pieces.tsx +383 -383
  98. package/src/pieces/index.ts +1 -1
  99. package/src/promotion-picker.tsx +147 -147
  100. package/src/static-board.tsx +186 -187
  101. package/src/themes.ts +129 -129
  102. package/src/types.ts +394 -373
  103. package/src/use-board-gesture.ts +459 -429
  104. package/src/use-board-pieces.ts +158 -158
  105. package/src/use-board-state.ts +120 -111
  106. package/src/use-premove.ts +59 -59
package/src/constants.ts CHANGED
@@ -1,103 +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
- /** 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;
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,101 +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
- 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';
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';